Sliding Window Maximum - Read Statement

Given an array nums and a window size kk, return the maximum value in each sliding window as it moves from left to right.

Example: For [1,3,-1,-3,5,3,6,7] and k=3k=3, output is [3,3,5,5,6,7]. The naive O(nk)O(nk) approach is too slow.