Your question is Sliding Window Maximum with Deque. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
NVIDIA Nsight Systems can produce a time-ordered stream of kernel durations or telemetry values. Given an integer array nums and a window size k, return the maximum value in every contiguous window as the window moves from left to right by one position.
Implement the solution in O(n) time using a deque. The deque should store indices, with corresponding values maintained in decreasing order.
nums, a non-empty list of integers, and k, an integer window size.n - k + 1 integers, where each integer is the maximum value in one window.nums[0:k], and the final output corresponds to nums[n-k:n].def max_window(nums, k):