description: Design an algorithm to encode a list of strings to a string. The encoded string is then sent over the network and is decoded back to the original list of strings
sidebar:
label: 'Encode and Decode Strings'
badge: 'Medium'
---
<Badge variant="accent">Array</Badge>
::::warning
Could you write a generalized algorithm to work on any possible set of characters?
The diagram traces the code below literally. That code does not solve the problem: both `encode` and `decode` have only a docstring for a body, so each returns `None` and `codec.decode(codec.encode(strs))` yields `None` instead of `strs`.
::::
```mermaid
flowchart TD
subgraph state["state — Codec holds no fields"]
X["Codec() — nothing is stored between encode and decode"]
end
subgraph encode["encode(strs)"]
E1["docstring only — no statement runs"] --> E2(["return None"])
end
subgraph decode["decode(s)"]
D1["docstring only — no statement runs"] --> D2(["return None"])