Encode and Decode Strings

Design an algorithm to encode a list of strings into a single string and decode it back. (Handle arbitrary contents including empty).

Input Format

N/A (design).

Output Format

N/A.

Constraints

  • Total encoded length <= 10^5.

Examples

Example 1:

Input:

strs = ["Hello","World"]

Output:

5#Hello5#World

Example 2:

Input:

strs = [""]

Output:

0#

Example 3:

Input:

strs = ["a","b","c"]

Output:

1#a1#b1#c
Loading...
Encode and Decode Strings - Strings DSA Problem