Problem
Write two functions. encode turns a list of strings into one string, and decode turns that string back into the original list. **Any characters may appear** in the strings, including #, commas, digits and empty strings, so a simple separator will break.
Example 1
- Input
- decode(encode(["hello", "world"]))
- Output
- ["hello", "world"]
Example 2
- Input
- decode(encode(["a#b", "", "3#x"]))
- Output
- ["a#b", "", "3#x"]
Example 3
- Input
- decode(encode([]))
- Output
- []
You choose the encoded format, as long as decode(encode(strs)) == strs for every list.
Constraints
0 <= strs.length <= 2000 <= strs[i].length <= 200strs[i] may contain any character. Do not rely on any character being absent.