Smallest Subsequence of Length K

Python Hard 4 views
Back to Questions

Problem Description

A string s and integer k are provided. Pick a subsequence of length k (keep order) with smallest lexicographic value. Output that subsequence.

Input Format

Line1: s. Line2: k.

Output Format

One line subsequence.

Sample Test Case

Input:
cbacdcbc 4
Output:
acdb

Constraints

1

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next