Created
July 25, 2020 13:36
-
-
Save Youngestdev/57c6a2b33cc9f944694c5112ca81a509 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
q, res = deque(), [] | |
for i, v in enumerate(nums): | |
while q and v > nums[q[-1]]: | |
q.pop() | |
while len(q) < min(i+1,k): | |
q.append(i) | |
if i >= k-1: | |
res.append(nums[q.popleft()]) | |
return res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment