#K11146. Counting Unique Letters
Counting Unique Letters
Counting Unique Letters
You are given a string S consisting of lowercase English letters and Q queries. Each query is represented as a pair of integers \(L\) and \(R\) (1-indexed). For each query, you are required to determine the number of unique letters in the substring of S from index \(L\) to \(R\) (inclusive).
The task is to write a program which, for every query, returns the count of distinct letters between indices \(L\) and \(R\) in the string.
Example:
Input: abcabc 1 1 3 Output: 3</p>Explanation: The substring from index 1 to 3 is "abc" which contains 3 unique letters.
inputFormat
The input is read from standard input (stdin) and is formatted as follows:
- The first token is the string S.
- The second token is an integer Q indicating the number of queries.
- This is followed by 2 * Q integers representing the queries. Each query consists of two integers \(L\) and \(R\) separated by whitespace.
outputFormat
For each query, print the number of unique letters in the specified substring on a new line to standard output (stdout).
## sampleabcabc 1 1 3
3