Implement a method to perform basic string compression on duplicate strings: aaaabbbbcccdddd => a4b4c3d4. However, if the compressed string would not be smaller than the original string, the function should return the original string. It can be assumed that the string in this case will only be composed of uppercase and lowercase letters.
Implement a method to perform basic string compression on duplicate strings: aaaabbbbcccdddd => a4b4c3d4. However, if the compressed string would not be smaller than the original string, the function should return the original string. It can be assumed that the string in this case will only be composed of uppercase and lowercase letters.