def mostCompetitive(self, nums: List[int], k: int) -> List[int]:
# if we need k element of the list we can't pass more than len(nums) - k times
pass_possibilities = len(nums) - k
stack = []
for num in nums:
# while there is element in stack and the current num is smaller than the top and we still have pass possibilites just pop
while stack and (num < stack[-1]) and (pass_possibilities > 0):
stack.pop()
pass_possibilities -= 1
stack.append(num)
return(stack[:k])