Back to problems

Compute letter frequencies from encoded string

Algorithm · Oracle · Medium

An encoded representation of a lowercase English string is defined as follows. Codes 1 through 9 stand for the letters a through i. Codes 10# through 26# stand for the letters j through z. If one letter occurs k consecutive times with $$k \ge 2$$, the letter's code is immediately followed by (k). For example, dd becomes 4(2) and kk becomes 11#(2). Given such an encoded string s, build an integer frequency array counts of length 26. counts[0] holds the number of occurrences…

Checking your access…