#C6396. Count Distinct Letters in Ranges
Count Distinct Letters in Ranges
Count Distinct Letters in Ranges
In this problem, you are provided with a string (s) consisting of uppercase English letters and a number of queries. Each query is defined by two integers (l) and (r), representing a 1-indexed inclusive range in (s). Your task is to compute the number of distinct letters in the substring (s[l...r]).
Note: The indices provided in the queries are 1-indexed, so you may need to convert them to 0-indexed when processing the string. For example, given (s = \texttt{ABCABCABC}) and the query ((1, 3)), the substring is (\texttt{ABC}), which contains 3 distinct letters.
inputFormat
The input is read from standard input (stdin) and has the following format:
1. A single line containing the string (s) (only uppercase English letters).
2. A line containing an integer (q), the number of queries.
3. (q) lines follow, each containing two space-separated integers (l) and (r) representing a query range.
outputFormat
For each query, output the number of distinct letters in the substring (s[l...r]) on a separate line on standard output (stdout).## sample
ABCABCABC
3
1 3
1 6
4 9
3
3
3
</p>