← All problems

Encode and Decode Strings

Medium stringsdesign LeetCode ↗
Design an encoding of a string list to a single string and back (strings may contain any chars).

Hints (0/3 revealed)

Log in to reveal hints progressively.

Complexity

Time O(n), Space O(n)

Common pitfalls

  • Using a separator character (breaks on data containing it)
  • Off-by-one in slicing

Your solution

Log in to save your code and track progress.