#C10668. Unique Substrings
Unique Substrings
Unique Substrings
You are given a string s consisting of lowercase English letters and a series of queries. Each query is defined by two integers start and end (0-indexed) representing the indices that define a substring s[start:end] (inclusive of both ends). Your task is to determine if each substring contains all unique characters, i.e. no character appears more than once.
Formally, for a substring s[i:j] (where j = end), check if \[ \text{substring} = s[i \ldots j] \quad \text{and} \quad |\text{substring}| = |\{ s[i], s[i+1], \ldots, s[j] \}|. \]
Print "True" if the substring has all unique characters, otherwise print "False".
inputFormat
The input is read from standard input and has the following format:
- A single line containing the string s.
- A line containing a single integer q representing the number of queries.
- q lines follow, each containing two integers start and end separated by a space.
Note that the indices are 0-indexed.
outputFormat
For each query, output a line containing either "True" or "False" (without quotes) to indicate whether the specified substring contains all unique characters.
## sampleabcde
3
0 4
1 3
2 2
True
True
True
</p>