Given an integer array nums sorted in nondecreasing order and an integer k, remove elements such that each distinct value appears at most k times while maintaining the original relative order.
Return the resulting array containing each element at most k times.
Note: The space used for returning or resizing the result does not count toward the auxiliary space complexity.
Constraints:
nums.length
nums[i]
nums is sorted in nondecreasing order.
k nums.length
Given an integer array nums sorted in nondecreasing order and an integer k, remove elements such that each distinct value appears at most k times while maintaining the original relative order.
Return the resulting array containing each element at most k times.
Note: The space used for returning or resizing the result does not count toward the auxiliary space complexity.
Constraints:
nums.length
nums[i]
nums is sorted in nondecreasing order.
k nums.length