Alphabetically smallest word

Given a string s made up of only lowercase letters, and a natural number
k, remove any substring of length k from s so that the result is the
lexicographically smallest possible word.

Input

Input consists of several cases, each with s and k. Assume
1 ≤ k < |s| ≤ 10⁴.

Output

For every case, print the alphabetically smallest word that can be
obtained after removing k consecutive letters from s.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T12:01:57.312Z

© Jutge.org, 2006–2026.
https://jutge.org
