from collections import deque
def func(nums, k, stride):
queue = deque()
res = []
n = len(nums)
step = 0
first = 1
for i in range(n):
step += 1
if queue and i - queue[0] + 1 > k:
queue.popleft()
while queue and nums[i] >= nums[queue[-1]]:
queue.pop()
queue.append(i)
if i + 1 >= k and (step == stride or first or i == n - 1):
res.append(nums[queue[0]])
step = 0
first = 0
return res