## 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

• onlyIfStatement
commented on Oct. 31, 2016 edited
Incorrect?

NVM

• Kirito
commented on Nov. 1, 2016 edit 2

Are you implying that all the people who have AC got it by accident? Your program is wrong, try the following input.

baaazzz
4
• onlyIfStatement
commented on Nov. 2, 2016 edited

IM A SPECIAL SNOW FLAKE

• Kirito
commented on Nov. 2, 2016 edited
• onlyIfStatement
commented on Nov. 2, 2016 edited

excuse my stupidity it's been a long week

• bobhob314
commented on Dec. 25, 2014
(: ^ o )

Python hax always provide a nice meme