Sliding Window Maximum
Updated
Problem statement
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]Each output is the largest value in the corresponding length-three window.
Example 2
nums = [1]k = 1return = [1]The only window contains the only value.
Example 3
nums = [9,8,7,6]k = 2return = [9,8,7]In a decreasing array, each window maximum is its leftmost value.
Constraints
1 <= nums.length <= 100000-1000000000 <= nums[i] <= 10000000001 <= k <= nums.length
More Bloomberg LP Onsite Interview questions
- Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Decode StringPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Minimum Replacements to Make Two Strings AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
Similar questions at other companies
- Shortest Subarray with Sum at Least KOracle · ONSITE INTERVIEWOracle interview questions
- Sliding Window MaximumGroww · PHONE SCREEN
- Sliding Window MaximumAmazon · ONSITE INTERVIEW
- Largest Value in Every Sliding WindowAdobe · PHONE SCREENAdobe interview questions
- Sliding Window MaximumPeopleStrong · ONSITE INTERVIEWPeopleStrong interview questions
- Sliding Window MaximumNVIDIA · PHONE SCREENNVIDIA interview questions
- Moving Average of a Data StreamSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
- Bad Request AlertsMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Longest Subarray Within an Absolute-Difference LimitGoogle · ONSITE INTERVIEWGoogle interview questions
- Longest Continuous Subarray Within an Absolute-Difference LimitUber · ONSITE INTERVIEWUber interview questions
Interview reports that mention this question
Bloomberg LP interview experiences
- Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
- Bloomberg SWE Intern Interview Questions: 68 Questions
- Bloomberg Interview Questions, Level Not Reported: 65 Questions
- Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
- Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)