Lexicographically Least Substring
View as PDFBrute Force Practice 2
You have a string (indexed from ) with no more than 
 lowercase characters. Find the lexicographically least substring with a length of at least 
. A string 
 is said to be lexicographically smaller than a string 
 if 
 and 
 is a prefix of 
 or 
 and 
 
. Here, 
 denotes the length of the string.
Input Specification
The first line will have the string.
The second line will have .
Output Specification
Print the lexicographically least substring of length at least .
Sample Input
iloveprogramming
4
Sample Output
ammi
Comments
I did length of only
 and passed, test cases are weak.
I think you might want to review the definition of lexicographical order.
Oh yeah.
He a little confused, but he got the spirit.
Python hax always provide a nice meme