Character Count
Easy · rating 950 · Strings
The first line is a string. The second line is a single character. Print how many times that character appears in the string.
Editorial
Character Count counts how many times a given character appears in a string — a single scan tallying matches, or a built-in count method.
print(s.count(ch))Complexity
Time: O(n). Space: O(1).
Related problems
- Capitalize Words — Easy
- Count Uppercase Letters — Easy
- Count Words — Easy
- Distinct Words — Easy
- Product of Digits — Easy
- Reverse a String — Easy