Skip to main content

Practice · 6 of 6

Run-length encode (flush the last run)

CHALLENGE
Difficulty: advanced+25 XP

Encode runs as <char><count>: "aaabbbcc" → "a3b3c2". Runs of length 1 still get the count. Implement process(String s) (empty string encodes to the empty string). This is the flush trap: the final run ends at the loop's last index, not inside it.

Back to lesson: Practice: String lab: transformations under constraints