题目描述
blablabla
样例
blablabla
算法1
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
python 代码
from collections import deque
class Solution(object):
def maxInWindows(self, nums, k):
"""
:type nums: List[int]
:type k: int
:rtype: List[int]
"""
res = []
q = deque([])
for i in range(len(nums)):
if len(q) != 0 and i - k >= q[0]:
q.popleft()
while len(q) != 0 and nums[i] > nums[q[-1]]:
q.pop()
q.append(i)
if i >= k -1 :
res.append(nums[q[0]])
return res