Code RoomVigenère encode
MediumPrep Room Coding #587

Vigenère encode

CodingAlgorithms & data structuresEntry–Mid~16 min

A puzzle channel encodes lowercase messages with a repeating keyword. The i-th letter of the message (counting only letters) is shifted forward by the alphabet index of the i-th keyword letter ('a' shifts by 0, 'b' by 1, ...), with the keyword repeating from its start when it runs out. Spaces are kept as-is and do not consume a keyword letter. The keyword is non-empty lowercase. For example, encoding 'hello' with key 'ab' gives 'hflmo'.

Implement
keyword_encode(message: str, key: str) → str
Examples
in["hello","ab"]out"hflmo"
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 16 min
InputExpectedGot
["hello","ab"]"hflmo"not run yetsample