FastPrepSliding Window Maximum
Problems/Sliding Window Maximum

Sliding Window Maximum

Amazon logoAmazon● HardNEW GRADONSITE INTERVIEW
QuestionFunctionExamples

Problem statement

Source note: This problem is backed by a real Amazon onsite interview report. The report directly named Sliding Window Maximum, but it did not include the exact function interface, examples, or constraints. The core task match is about 95%.

Given an integer array nums and a window size k, return the maximum value in every contiguous window of length k, from left to right.

Function

maxSlidingWindow(nums: int[], k: int) → int[]

Examples

Example 1

nums = [1,3,-1,-3,5,3,6,7]k = 3return = [3,3,5,5,6,7]

Example 2

nums = [1]k = 1return = [1]

More Amazon problems

  • Count Adjacent Symbol Pairs for BPEONSITE INTERVIEW · Seen Nov 2026
  • First Non-Repeating CharacterOA · ONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
See Amazon hiring insights
Saved
class Solution {
    public int[] maxSlidingWindow(int[] nums, int k) {
      // write your code here
    }
}
Checking account…