Skip to interview prep
Apexed
Problem list114 / 125

114. Sliding Window Maximum

HardQueues

Return the maximum of every contiguous window of size k in nums, from left to right.

Example 1

Input: nums = [1, 3, -1, -3, 5, 3, 6, 7], k = 3
Output: [3, 3, 5, 5, 6, 7]

Constraints

  • 1 ≤ k ≤ nums.length ≤ 10⁵

Tab indents · Ctrl/⌘ + Enter runs · Esc then Tab leaves the editor

Run checks these cases; the expected output comes from the reference solution. Submit judges all 4 hidden and sample tests.

Code runs only in your browser in an isolated sandbox. Progress and submissions are saved on this device.

Sliding Window Maximum — coding interview practice — Apexed