Encode and Decode Strings
Implement encode(strings) returning one string and decode(encoded) recovering the original string array. Choose any unambiguous format; empty strings and delimiter characters must survive a round trip.
Example 1
strs = ["a#b","","12#","hello"]["a#b","","12#","hello"]Explanation
Recover all four strings exactly, including embedded # characters, an empty string, and numeric prefixes.
Example 2
strs = [][]Explanation
An empty list must decode to no elements.
Example 3
strs = ["",""]["",""]Explanation
Two empty strings must remain two elements rather than collapse into an empty list.
Constraints
- 0 <= number of strings <= 100
- Each string contains at most 200 ASCII characters
- decode receives a value produced by encode
Function contract
encodeArguments: jsonSolutionRuns on your device
Loading draft…
Run: 3 examples; Submit: 33 cases, on your device.
["a#b","","12#","hello"]