## Lexicographically Least Substring

View as PDF

Points: 5
Time limit: 2.0s
Memory limit: 64M

Problem types
##### Brute 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

The first line will have the string.

The second line will have .

#### Output

Print the lexicographically least substring of length at least .

#### Sample Input

iloveprogramming
4

#### Sample Output

ammi

• commented on Jan. 16, 2020, 2:10 p.m.

I did length of only K and passed, test cases are weak.

• commented on Jan. 16, 2020, 2:32 p.m.

I think you might want to review the definition of lexicographical order.

• commented on Aug. 13, 2020, 11:06 p.m.

Oh yeah.

• commented on Jan. 16, 2020, 9:26 p.m.

He a little confused, but he got the spirit.

• commented on Dec. 25, 2014, 11:25 a.m.

Python hax always provide a nice meme