Distinct characters
Practice
4 (2 votes)
Medium
Hiring
Range query
Recruit
Data structures
Strings
Problem
58% Success 607 Attempts 30 Points 1.5s Time Limit 256MB Memory 1024 KB Max Code
You are given a string S of length N and there are Q queries. In each query, you are provided with 2 integers L and R. You need to find the number of distinct characters present in the range L to R.
Input :
- First line of Input contains N , length of string S.
- Second line of input contains string S containing lowercase alphabets only.
- Third line of Input contains Q , number of queries
- Each following Q lines contains 2 integers , L and R .
Output :
For each query , output number of distinct characters in newline .
Constraints :
- \( 1 \le N \le 10^{5} \)
- \( 1 \le Q \le 10^{5} \)
- \( 1 \le L \le R \le N \)
Submissions
Please login to view your submissions
Similar Problems
Points:30
47 votes
Tags:
AlgorithmsApprovedBit ManipulationDynamic ProgrammingMediumReady
Points:30
Tags:
MathematicsSieveEasy-MediumNumber TheoryFactorization
Points:30
72 votes
Tags:
Binary SearchHash MapsMediumOpenSorting
Editorial