All Tracks Problem

Super String
Tag(s):

Easy

Problem
Editorial
Analytics

Kevin has a string $$S$$ that consists of lowercase English letters. Also he can perform the following operation in one minute:

  • Choose some $$L,R$$ such that $$1 \le L \le R \le length(S), L \ne 1 \space $$ or $$\space R \ne length(S)$$ and remove substring $$[L, R]$$ from $$S$$. It means that string $$S=S_1 S_2 \dots S_{length(S)}$$ becomes $$S_1 S_2 \dots S_{L-1} S_{R+1} \dots S_{length(S)}$$.

Kevin has at most $$K$$ minutes to perform this operations. He decides that the string is super if it is the lexicographically smallest among all possible strings that he can get. Your task is to help Kevin and find this lexicographically smallest string.

Input format:

The first line of input will contain an integer $$T$$, denoting the number of test cases.
Each test case starts with 2 numbers $$N$$ and $$K$$ - length of $$S$$ and the number of minutes Kevin has. Next line contains string $$S$$.

Output format:

For every test case output lexicographically smallest string that Kevin can get.

Constraints:

  • $$1 \le T \le 10$$
  • $$1 \le N, K \le 1000$$
SAMPLE INPUT
1
4 2
meow
SAMPLE OUTPUT
e
Explanation

Kevin get string "eow" after the first operation and "e" after the second.

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

HackerEarth

Challenge Name

September Clash '16

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications