Implement basic string compression using the counts of repeated characters.
For example, the string "aabcccccaaa" would become "a2b1c5a3".
If the compressed string would not become smaller than the original string, return the original string. You can assume the string has only lowercase and uppercase English letters.
Note that consecutive runs of the same character are compressed independently. The string "aabaa" becomes "a2b1a2", not "a4b1".
s = "aabcccccaaa""a2b1c5a3"s = "abcdef""abcdef"s = "aaaa""a4"0 <= s.length <= 10^4s contains only English letters (uppercase and lowercase)Run your code to see results
Use Cmd+Enter to run