Count The Occurrence of a given Character in String

Given a string and a character that we have to search. This problem can be used to solve many problems like removing duplicates or removing unwanted characters from strings.

This problem can be solved using count() or using a collections module or using the native method.

For example:
Input: string = "pythonisawesome",  char = "e"
Output: 2


Thank you so much for reading this article, if you like this question please share this with your friends who love programming. And if you have questions or feedback please drop a comment.

To solve more problems, please check out this article "Top 10 String Interview Questions".

All the Best!

Comments

Popular posts from this blog

Four Sum Problem (4sum) Solution in Java, Python, C++

Find the length of the longest substring without repeating character

Reverse Words in a Sentence Without using any Library