73. Character Frequency
Core1000 ms256 MBSolved by 0%
Read a line of text, then a single character on the next line.
Print how many times that character appears in the line. The comparison is
case-sensitive: A and a are different characters.
Constraints - The line has between 1 and 100000 characters. - Printable ASCII only.
Input
The first line contains the text. The second line contains the single character to count.
Output
Print one integer, how many times the character appears in the line.
Inputhello world
l
Output3
Notecounts a letter appearing three times
InputHello
h
Output0
Noteis case-sensitive, so lowercase h does not match uppercase H
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.
Hint 1Where to start
Hint 2The approachOpen hint 1 first. This one carries on from it.
Hint 3PseudocodeOpen hint 2 first. This one carries on from it.
Hint 4Full solutionOpen hint 3 first. This one carries on from it.