An assembly line's barcode scanner logs one uppercase letter for every component that passes it, in the order the components arrive, producing a single scan-log string. Quality control wants to know what fraction of the logged components belong to one particular component code. Given the scan-log string and a target component code, compute the percentage of characters in the log equal to the target code, rounded down to the nearest whole percent.
Print a single integer: the percentage of characters of s equal to the target letter, rounded down to the nearest whole number.
Example 1
Input
AABBCCDD B
Expected
25
Explanation
The log "AABBCCDD" has 8 characters, of which 2 are 'B'. 2*100/8 = 25 exactly, so the answer is 25.
Example 2
Input
ZZZZZ Z
Expected
100
Explanation
Every one of the 5 characters in the log is 'Z', so the percentage is 5*100/5 = 100.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →