This method takes a String object as a parameter and returns a compressed version of the object. The method compresses the String by...
X581: compressString
This method takes a String object as a parameter and returns a compressed version of the object. The method compresses the String by replacing repeated characters with the number of such characters. However, if the length of the compressed version is not smaller than the parameter, the method returns the original String. For example, if the parameter String is "bbbaaccccd", the method returns"b3a2c4d1"; if the parameter String is "abccdeff", the method returns "abccdeff". You can assume that the String only contains uppercase and lower case letters.
Examples:
compressString("bbbaaccccd") -> "b3a2c4d1"
compressString("abccdeff") -> "abccdeff"
Your Answer:
Feedback
Your feedback will appear here when you check your answer.