:type nums: List[int] :type k: int :rtype: List[int]
(self, nums, k)
| 60 | hi = mid |
| 61 | |
| 62 | def maxSlidingWindow(self, nums, k): |
| 63 | """ |
| 64 | :type nums: List[int] |
| 65 | :type k: int |
| 66 | :rtype: List[int] |
| 67 | """ |
| 68 | if not nums: |
| 69 | return [] |
| 70 | |
| 71 | x = nums[:k] |
| 72 | y = sorted(x) |
| 73 | x = deque(x) |
| 74 | |
| 75 | maxes = max(x) |
| 76 | result = [maxes] |
| 77 | |
| 78 | for i in nums[k:]: |
| 79 | pop = x.popleft() |
| 80 | x.append(i) |
| 81 | |
| 82 | index = self.find_bi(y, pop) |
| 83 | y.pop(index) |
| 84 | |
| 85 | bisect.insort_left(y, i) |
| 86 | |
| 87 | result.append(y[-1]) |
| 88 | return result |
| 89 |