Practice Interview Questions
| Question | Status |
|---|---|
Given a string consisting of repeated characters, write a function to compress the string. The compression should count the consecutive occurrences of each character and append the character followed by the count.
The function should be case sensitive, meaning that 'A' and 'a' are treated as different characters. Single or double letters can also be compressed (e.g., 'AAB' can be compressed to 'A2B1').
Example:
Input: "AAAABBBBCCCCCDDEEEE"
Output: "A4B4C5D2E4"
Input: "AAAaaa"
Output: "A3a3"