lint
code
love
you
[0][1][2][3]
Naive delimiter (why it breaks)
▸1encode(words): return words.join("#")2decode(s): return s.split("#")3// FAILS: a word containing "#" is split apart
state
- sep#
Your free access ends in 7 days — and you haven’t tried it yet. Watch one algorithm run, start to finish. It takes about two minutes.
Try one problemDesign encode(list<string>) → string and decode(string) → list<string> so that the original list is recovered exactly. The strings may contain ANY characters, including whatever you pick as a delimiter.
▸1encode(words): return words.join("#")2decode(s): return s.split("#")3// FAILS: a word containing "#" is split apart
line 1First idea: join the words with a separator like "#", e.g. "lint#code#love#you", and split on "#" to decode. Simple — but it secretly assumes no word ever contains "#".