A new video about the recent developments in coding has been published on the HackerEarth social media handle. After some time, it is seen that there are N comments added. The admin wants to see if there are any derogatory comments. Hence, he searched the comment section with a keyword S.
Task
Give the count of the comments that will be returned as a result of the search.
Notes
- The count can be 0.
- The algorithm searches the keyword irrespective of the case of the word.
- The separator here is “_”.
Example 1
Assumptions
Input
- N = 3
- S = “hate”
- comments = [“The_video_is_good”, “I_hate_this”, “Informative”]
Output: 1
Approach
Only the second comment contains the word “hate”.
Function description
Complete the function solution() provided in the editor. The function takes the following 3 parameters and returns the solution:
- N: Represents the number of comments
- S: Represents the keyword
- comments: Represents the array of comments
Input format
Note: This is the input format that you must use to provide custom input (available above the Compile and Test button).
- The first line contains N denoting the number of comments.
- The second line contains S denoting the keyword.
- Each of the next N lines contains a string denoting a comment.
Output format
Print an integer representing the number of comments containing the keyword.
Constraints
Given
Input
- N = 2
- S = “bad”
- comments = [“The_video_is_BAD”, “bad_bad_bad”]
Output: 2
Approach
Both comments contain the keyword “bad”.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor