Easy · Strings
Run-Length Encoding
Given an ASCII 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
Core interview problems are free with a full runner and lessons; Pro opens the complete library.