FreeCareerPath
Build the PrimitiveMedium

Encode and Decode Strings

Implement `encode(strings)` and `decode(text)` so that `decode(encode(xs)) == xs` for any list of strings, including empty strings and strings containing any character at all. encode(["hi", "there"]) -> some single string decode(that string) -> ["hi", "there"] Any delimiter you choose can appear inside the data. That is the whole question, and the answer is framing: write each string's length, then a marker, then the bytes — so the decoder never has to guess where a string ends.

What to expect: A timer starts when you begin. Edit the starter code, run it against the test suite as many times as you like, then finish when you're done. The reference solution and interviewer follow-up questions unlock only after you finish.

Log in to start this session

Timed sessions and your results for "Encode and Decode Strings" are saved to your account — logging in takes a few seconds.