Count Full-Line Comments
Easyjava
Count how many of the given lines are full-line single-line comments — that is, the first non-whitespace characters on the line are //.
Input: the first line is an integer N; then N lines of text.
Output: one line — the number of full-line // comments.
Example 1
Input
4 // header int x = 1; // indented note y = 2; // trailing
Output
2
- 1 <= N <= 100
Hint 1
line.trim() removes leading spaces so an indented comment still counts.
Hint 2
startsWith("//") on the trimmed line is the test.
Hint 3
A line with code before // does not count.
Trim each line first so indentation does not matter, then check whether it begins with //. A trailing comment after code (like y = 2; // trailing) is not a full-line comment and is not counted.