META | Onsite | Sliding Window Maximum

Sliding Window Maximum

Note: (I edited to make it more short)
Problem:

Given an array nums and an integer k, find the maximum value in each sliding window of size k.

Constraints: Must operate in O(n) time complexity.

Example:

Input: nums = {1,3,-1,-3,5,3,6,7}, k = 3  
Output: {3,3,5,5,6,7}

Please give an upvote if helpful

Comments (7)