Lexicographically Smallest Subsequence

medium
1. Given an integer array nums and a positive integer k;
2. return the lexicographically smallest subsequence of size k;

Input Format

Input is managed for you

Output Format

Output is managed for you

Constraints

1. 1 <= nums.length <= 10^5
2. 1 <= nums[i] <= 10^9
3. 1 <= k <= nums.length

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
8
2
4
3
3
5
4
9
6
4
Output
4
2
3
3
4
Previous
Basic Calculator Iii
Next
Max-stack

Related Questions