#K15636. K-th Distinct Character Finder
K-th Distinct Character Finder
K-th Distinct Character Finder
You are given a string s consisting of lowercase English letters and an integer Q representing the number of queries. Each query contains an integer k. For each query, you need to find the k-th distinct character in the order of their first appearance in s. If there are fewer than k distinct characters, output None
.
Let \(D = [d_1, d_2, \dots, d_m]\) be the array of distinct characters taken from s (in the order they appear). For a given query \(k\), if \(k \leq m\) then output \(d_k\); otherwise, output None
.
Input/Output Format:
inputFormat
Input Format:
- The first line contains the string s.
- The second line contains an integer Q, the number of queries.
- The third line contains Q space-separated integers, each denoting a query value k.
outputFormat
Output Format:
- For each query, print the k-th distinct character on a new line. If the k-th distinct character does not exist, print
None
(without quotes).
abacabad
3
1 3 5
a
c
None
</p>