Remove a Block Comment
Mediumjava
A single line of code may contain one /* ... */ block comment. Remove it. If there is a single space immediately before the /*, remove that space too. Print the resulting line.
Input: one line of text (it may or may not contain /* ... */).
Output: one line — the text with the block comment removed.
Example 1
Input
a = 1; /* init */ b = 2;
Output
a = 1; b = 2;
- the line has at most 200 characters
- at most one /* ... */ per line
Hint 1
indexOf("/*") and indexOf("*/") locate the comment.
Hint 2
before = text up to /*, after = text from */ + 2.
Hint 3
If before ends with a space, drop that one space; then print before + after.
Locate / and /. Everything before / and everything after / is kept; the comment itself is dropped. Removing one space before / keeps the spacing tidy, turning "a = 1; / init */ b = 2;" into "a = 1; b = 2;". A line with no block comment is printed unchanged.