Test Cases
Case 1
Case 2
Case 3
Input
"aabcccccaaa"
Output
"a2b1c5a3"
Implement a function 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 function should return the original string. You can assume the string has only uppercase and lowercase letters (a-z).
Input: str - A string containing only uppercase and lowercase letters (a-z). Output: A compressed string with repeated characters followed by their counts, or the original string if the compressed version is not shorter.
Example 1
Input: "aabcccccaaa"
Output: "a2b1c5a3"
Example 2
Input: "abcdef"
Output: "abcdef"
Example 3
Input: "zzzbbb"
Output: "z3b3"
Input
Output