Easy · Strings
Run length encoding
Given a string s, return its run-length encoding: each maximal run of equal adjacent characters becomes that character followed by the run's length in decimal ("aaabbc" → "a3b2c1"); an empty s returns "".
Examples
Example 1
{
"s": "aaabbc"
}Output: "a3b2c1"
Example 2
{
"s": "wwwwaaa"
}Output: "w4a3"
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.