Your question is Alphabet Type and Frequency Encoding. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
StubHub processes compact text labels for event listings. Implement run-length encoding for consecutive alphabetic characters, returning the encoded string only when it is strictly shorter than the original.
Given a string s containing uppercase and lowercase English letters, encode each maximal consecutive run as the character followed by its count when the count is greater than one. A run of length one is represented by the character alone. If the encoded string is not shorter than s, return s unchanged. Preserve character case and run order.
Implement compress_listing_text(s) and return a string.
def compress_listing_text(s):