Sliding Window Maximum
Updated
Problem statement
Given an integer array nums and a window size k, return the maximum value in each contiguous window of exactly k elements. Move the window one position at a time and return the maxima from left to right.
Function
maxSlidingWindow(nums: int[], k: int) → int[]Examples
Example 1
nums = [4,1,3,2,5]k = 3return = [4,3,5]The three windows have maxima 4, 3 and 5.
Example 2
nums = [-4,-1,-3]k = 2return = [-1,-1]Both windows contain -1; negative values remain valid maxima.
Example 3
nums = [2,2,1]k = 3return = [2]A window spanning the entire array produces one result.
Constraints
1 <= nums.length <= 10^5.-10^4 <= nums[i] <= 10^4.1 <= k <= nums.length.
More NVIDIA Phone Screen questions
- Network Layer Execution OrderPHONE SCREEN · Seen Nov 2026
- Paged KV Cache AccessPHONE SCREEN · Seen Nov 2026
- Sliding Window Attention over a KV CachePHONE SCREEN · Seen Nov 2026
- Summarize Server Healthcheck LogsPHONE SCREEN · Seen Oct 2026
- Hash Partition OffsetsPHONE SCREEN · Seen Oct 2026
- Filter Paginated Medical RecordsPHONE SCREEN · Seen Oct 2026
- Least Frequently Used CachePHONE SCREEN · Seen Oct 2026
- Parallel String Counts with a Custom Hash TablePHONE SCREEN · Seen Oct 2026
- Simulate a Reference-Counted Smart PointerPHONE SCREEN · Seen Aug 2026
- Streaming Top-K Frequent ElementsPHONE SCREEN · Seen Aug 2026
Similar questions at other companies
- Sliding Window MaximumGroww · PHONE SCREEN
- Largest Value in Every Sliding WindowAdobe · PHONE SCREENAdobe interview questions
- Sliding Window MaximumBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Moving Average of a Data StreamSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
- Disk Space Window AnalyzerAgoda · PHONE SCREENAgoda interview questions
- Longest Continuous Subarray Within an Absolute-Difference LimitOracle · PHONE SCREENOracle interview questions
- Transcript Window MetricsSesame · PHONE SCREEN
- Sliding Window MaximumAkuna Capital · PHONE SCREENAkuna Capital interview questions
- Sliding Window Average (Meta Canada, E4/E5 :)Meta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
- Incident MonitorStripe · OAStripe interview questions