Lexicographically Least Substring (Hard)View as PDF
Brute Force Practice 2 — Hard Version
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.
The first line will have the string.
The second line will have .
Print the lexicographically least substring of length at least .