Question description
You are given a string of length , consisting of only lowercase English letters.
Find the lexicographically smallest substring of with a length of and output it.
Note:
A substring of a string is a string obtained by removing 0 or more characters from and concatenating the remaining characters in their original order.
The definition of lexicographic order:
Let and be two different strings. is said to be lexicographically smaller than if and only if is a prefix of , or if is the smallest integer such that , and .
Constraints
- is a string of length consisting of lowercase English letters
- , are integers
Input
The input is given in the following format:
Output
Output the answer as a string.
Examples Input example
7 3
atcoder
Output example
acd
In this example, we can obtain the string "acd" by taking only the 1st, 3rd, and 5th characters.
This string is the lexicographically smallest 3-character substring among all possible substrings.
Approach
Complexity Analysis
- time complexity :
Solution