Algorithm · Oracle · Easy
Implement a run-length encoder for a string. Given s, walk through it from left to right and divide it into maximal contiguous blocks where every character in the block is the same. For each block, put the block's character into the result. When a block contains more than one character, put its exact length as a decimal number directly after the character. Join all encoded blocks together and return that string. If s has length zero, return an empty string. Example 1:…
Checking your access…