Search⌘ K
AI Features

DIY: Count a Word in the Comments

Understand how to accurately detect comments in C++ source code and count occurrences of a given word within them. This lesson helps you develop skills in parsing code and working with strings to solve practical programming interview problems.

Problem statement

In this challenge, you are given two arguments: a list of strings containing lines of a C++ source code and a string containing a word. Your task is to identify which parts of the code are comments, and then count all occurrences of the input word present in the comments of ...