#C5179. Count Distinct Characters on the Longest Page
Count Distinct Characters on the Longest Page
Count Distinct Characters on the Longest Page
You are given a notebook represented as a string. The notebook contains multiple pages separated by newline characters (\n
), and each page may contain noise characters represented by the hash symbol #
. Your task is to determine the page (after removing all #
characters) with the longest length and then output the count of distinct characters on that page.
Note: If there are multiple pages with the same maximum length, consider the first one encountered. If the input is empty, the output should be 0.
Examples:
- Input:
abc#d\nef##ghi\njklmn###op\n
→ Output:7
- Input:
a#b#c#d#e#f
→ Output:6
- Input:
abc#d#\nef#\nghi#j\n
→ Output:4
- Input:
(empty) → Output:
0
- Input:
#\n#\n#
→ Output:0
inputFormat
The input is read from standard input (stdin
) as a string representing the notebook. The string may span multiple lines. Each newline character (\n
) denotes the end of a page, and each page may contain noise characters represented by the hash symbol (#
) which should be ignored.
outputFormat
Output a single integer to standard output (stdout
), which indicates the number of distinct characters on the longest page after removing all occurrences of #
.
abc#d
ef##ghi
jklmn###op
7