PIXELBANKv9.1.0
Menu

Design an algorithm to encode a list of strings into a single string and decode it back.

Input: comma-separated strings. Output: decoded strings, one per line.

Example:

Input:
hello,world
Output:
hello
world
Reasoning:
  • The input string "hello,world" is split into a list of strings using the comma as a delimiter, resulting in ["hello", "world"].
  • Each string in the list is then encoded into a single string with a length prefix, but in this case, the problem description implies a simple split is sufficient for decoding.
  • The encoded string is not explicitly needed for the output, so we proceed to decode the input string directly by splitting it into substrings.
  • The decoded strings are then printed one per line, resulting in the output:

hello world

Constraints:

  • 0 <= len(strs) <= 200
  • 0 <= len(strs[i]) <= 200
  • strs[i] may contain any character including commas
🔒

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test Results

0/0
Run code to see test results.