String Compression
Medium · Strings
Write a function compress that replaces every run of the same character with the character followed by the length of the run.
Single characters also get a count, so "abc" becomes "a1b1c1".
Next: Title Case
Medium · Strings
Write a function compress that replaces every run of the same character with the character followed by the length of the run.
Single characters also get a count, so "abc" becomes "a1b1c1".
Next: Title Case