Given an array and a window size k, return an array of the maximum value in each sliding window of size k as it moves from the very left of the array to the very right.
nums = [1,3,-1,-3,5,3,6,7], k = 3[3,3,5,5,6,7]nums = [1], k = 1[1]Solve it in the editor. Sign in free to run your Python or JavaScript against test cases, get a verdict, and track your attempts.
Solve on FeatCode →A window — a contiguous subarray or substring — expands and shrinks as it moves across the input, so you track a running condition instead of recomputing it from scratch for every possible window.
Read the full Sliding Window guide →
Original problem on LeetCode ↗