String Compression
Implement a method to perform 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, your method should return the original string.
You can assume the string has only uppercase and lowercase letters (a-z).
Examples:
compress("aabcccccaaa") → "a2b1c5a3"
compress("abcd") → "abcd" (compressed is longer)
compress("aabb") → "aabb" (same length, return original)
Hints
solution.py
Python ready
Test Output
▶
Click "Run Tests" to execute your code