CT126

Compress the Ribbon Pattern

EasyL2 · Byte BanditAcceptance: 0.0%XP: 10

A ribbon maker stores each run of matching lowercase beads as its letter followed by the run length. Task: Run-length encode the lowercase token, including counts of one. Input format: One nonempty lowercase English word s. Output format: Print each consecutive run as its character followed by the run length. Constraints: 1 <= length(s) <= 100000

Example 1:

Input: aaabbc
Output: a3b2c1

Example 2:

Input: z
Output: z1

Example 3:

Input: abcd
Output: a1b1c1d1

Constraints:

1 <= length(s) <= 100000

Tags:

strings run-length-encoding
Loading...
Test Cases:No test cases
No test cases available.