原题题目
代码实现(首刷自解)
class Solution {
public:vector<int> mostCompetitive(vector<int>& nums, int k) {
vector<int> ret;if(nums.size() == k) return nums;for(int i=0;i<nums.size();++i){
while(ret.size() && nums[i]<ret.back() && ((nums.size()-i>=k) || (ret.size() >= k+i+1-nums.size()))) ret.pop_back();if(ret.size() < k) ret.emplace_back(nums[i]); }return ret;}
};