#K74612. Maximizing Distinct Characters After Deletion
Maximizing Distinct Characters After Deletion
Maximizing Distinct Characters After Deletion
You are given a string \(s\) consisting of lowercase English letters with a length satisfying \(1 \leq |s| \leq 400{,}000\). You must delete exactly one character from \(s\) in order to maximize the number of distinct characters in the remaining string.
Note: If \(|s|=1\), deleting the only character will result in an empty string, so the answer is 0.
Example: For \(s = \texttt{abbc}\), by deleting one of the duplicate 'b' characters you can achieve \(\{a, b, c\}\), giving an answer of 3.
Your task is to compute and output the maximum possible number of distinct characters after the deletion.
inputFormat
A single line containing the string (s).
outputFormat
Output a single integer: the maximum number of distinct characters that can be obtained after deleting exactly one character from (s).## sample
abbc
3