You are given a line of n lowercase Latin letters, the word that Fischl recently expressed. You believe that the MEX of this string might assist you with tracking down the significance behind this message. The MEX of the string is characterized as the briefest string that doesn't show up as a touching substring in the input. On the off chance that different strings exist, the lexicographically littlest
python only. correct answer will upvoted else downvoted.
You are given a line of n lowercase Latin letters, the word that Fischl recently expressed. You believe that the MEX of this string might assist you with tracking down the significance behind this message. The MEX of the string is characterized as the briefest string that doesn't show up as a touching substring in the input. On the off chance that different strings exist, the lexicographically littlest one is viewed as the MEX. Note that the unfilled substring doesn't consider a substantial MEX.
A string an is lexicographically more modest than a string b if and provided that one of the accompanying holds:
a will be a prefix of b, yet a≠b;
in the main position where an and b contrast, the string a has a letter that shows up prior in the letters in order than the comparing letter in b.
A string a will be a substring of a string b if a can be gotten from b by cancellation of a few (perhaps, zero or all) characters all along and a few (potentially, zero or all) characters from the end.
Discover what the MEX of the string is!
Input
Each test contains different experiments. The main line contains the number of experiments t (1≤t≤1000). Depiction of the experiments follows.
The main line of each experiment contains an integer n (1≤n≤1000) — the length of the word. The second line for each experiment contains a solitary line of n lowercase Latin letters.
The amount of n over all experiments won't surpass 1000.
Output
For each experiment, output the MEX of the string on another line.
Step by step
Solved in 4 steps with 2 images