Design an algorithm to encode a list of strings to a single string and decode it back.
Design an algorithm to encode a list of strings into a single string for transmission, and decode it back to the original list. Strings may contain any characters.
Examples
Input:["s0","","","xa"]
Output:["s0","","","xa"]
Input:["s1","","#","xb"]
Output:["s1","","#","xb"]
Hints
Use a length prefix: encode as "length#string".
When decoding, read the length first, then extract that many characters.