Comment section
Practice
2 (4 votes)
String searching
Algorithms
Real world
String algorithms
Problem
88% Success 1035 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

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

\(1 \le N \le 10^5 \\ 1 \le |S| \le 10 \\ 1 \le Sum\: of\: length\: of\: all\: comments \le 10^5 \\ S\: and\: comments\: contain\: only\: lower\: and\: upper\: case\: latin\: characters\: and\: underscores\)

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

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
42 votes
Tags:
Data StructuresEasySortingString Manipulationapproved
Points:20
24 votes
Tags:
ApprovedEasyString Manipulation
Points:20
13 votes
Tags:
AlgorithmsString ManipulationTwo pointer