Tap here to switch tabs
Problem
Submissions

Problem: Find the Most Competitive Subsequence

Find the Most Competitive Subsequence asks you to choose a subsequence of exactly k elements from an integer array, returning the one that is lexicographically smallest.

Statement

Given an integer array nums and an integer k, return the most competitive subsequence of nums of size k.

A subsequence a of length k is considered more competitive than another subsequence b of length k if, at the first position where a and b differ, the value in a is strictly smaller than the value in b.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 0≤0 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq k ≤\leq nums.length

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find the Most Competitive Subsequence

Find the Most Competitive Subsequence asks you to choose a subsequence of exactly k elements from an integer array, returning the one that is lexicographically smallest.

Statement

Given an integer array nums and an integer k, return the most competitive subsequence of nums of size k.

A subsequence a of length k is considered more competitive than another subsequence b of length k if, at the first position where a and b differ, the value in a is strictly smaller than the value in b.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 0≤0 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq k ≤\leq nums.length