271. Encode and Decode Strings
Practice Encode and Decode Strings for free on NudgeCode: Medium, Array & Hash Table pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
Design a way to pack a list of strings into one string (encode) and unpack it back into the same list (decode). The strings can contain any printable ASCII character, including whatever separator you might want to use, so plain joining on a delimiter is not enough.
The tests check that decode(encode(strs)) equals strs.
Example
strs = ["neet","code","love","you"] -> ["neet","code","love","you"]
Constraints
- 0 <= strs.length <= 200
- 0 <= strs[i].length <= 200
strs[i]contains printable ASCII characters