Run-Length Encoding

Given a string, perform run-length encoding (e.g. "aaabb" → "a3b2").

Input Format

One line string s.

Output Format

Encoded string.

Constraints

  • 1 <= len(s) <= 10^5.

Examples

Example 1:

Input:

s = "aaabb"

Output:

a3b2

Explanation:

Three 'a's then two 'b's.

Loading...
Run-Length Encoding - Strings DSA Problem