Sliding Window Maximum

Hard Solved

Description

You are given an array of integers nums and an integer k. There is a sliding window of size k which moves from the very left of the array to the very right.

Return the maximum value in each sliding window.

Input format:

  • Line 1: JSON array of integers (nums)
  • Line 2: Integer k

Example

Input:
[1,3,-1,-3,5,3,6,7]
3

Output:
[3,3,5,5,6,7]

Note:

Print the result as a JSON array so it can be compared with expected output.

No submissions yet.

Discuss deque-based optimization, brute-force approach, and time complexity improvements.

Test Cases