Code Room
CodingMediumcod-g1393
Subject StringsLevel Entry–Mid~16 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.