loading…
Write compress(s) that turns runs of the same letter into letter + count: "aabcccccaaa" → "a2b1c5a3". If the result is not shorter than s, return s unchanged.
compress("aabcccccaaa") -> "a2b1c5a3"
compress("abc") -> "abc"
Stuck on the idea itself? The strings lesson walks through the pattern from scratch.