FastPrepSliding Window Maximum
Problems/Sliding Window Maximum

Sliding Window Maximum

PeopleStrong logoPeopleStrong● HardFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a PeopleStrong onsite interview. The candidate reports Sliding Window Maximum, from brute force to the best approach, with dry runs and follow-ups. We chose the function interface and the limits. Our version is about 95% the same as the reported question.

Given an integer array nums and a window size k, return the maximum value in every consecutive window of exactly k elements. Return the maxima in order from the leftmost window to the rightmost.

For this exercise, assume the array is nonempty and the window size is valid. Values may be negative and may repeat.

Function

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

Examples

Example 1

nums = [4,2,12,3,8,7]k = 3return = [12,12,12,8]

The four windows are [4,2,12], [2,12,3], [12,3,8] and [3,8,7]. Their maxima are 12, 12, 12 and 8.

Example 2

nums = [-4,-2,-9]k = 1return = [-4,-2,-9]

Each one-element window returns its own value, including negative values.

Constraints

  • For this exercise, assume 1 <= nums.length <= 10^5.
  • 1 <= k <= nums.length.
  • -10^9 <= nums[i] <= 10^9.

More PeopleStrong Onsite Interview questions

  • Add Two Binary StringsONSITE INTERVIEW · Seen Mar 2026
  • Four SumONSITE INTERVIEW · Seen Mar 2026
  • LRU Cache OperationsONSITE INTERVIEW · Seen Mar 2026
  • Find the Entry of a Linked List CycleONSITE INTERVIEW · Seen Sep 2025
  • Integer to English Words: Up to 20 DigitsONSITE INTERVIEW · Seen Sep 2025
  • Word Ladder II: All Shortest TransformationsONSITE INTERVIEW · Seen Sep 2025
  • Detect a Cycle in a Linked ListONSITE INTERVIEW · Seen May 2025
  • First Nonrepeating CharacterONSITE INTERVIEW · Seen May 2025
  • Longest Subarray with a Target SumONSITE INTERVIEW · Seen May 2025
  • Lowest Common Ancestor in a BSTONSITE INTERVIEW · Seen May 2025

Similar questions at other companies

  • Sliding Window MaximumAmazon · ONSITE INTERVIEW
  • Sliding Window MaximumBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP 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
  • Sliding-Window Rate LimiterSnowflake · ONSITE INTERVIEWSnowflake interview questions
  • Fixed-Window Rolling MeanJump Trading · ONSITE INTERVIEWJump Trading interview questions
  • Sliding Window Average (Meta Canada, E4/E5 :)Meta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Incident MonitorStripe · OAStripe interview questions
  • Sliding Window MaximumGroww · PHONE SCREEN
  • Largest Value in Every Sliding WindowAdobe · PHONE SCREENAdobe interview questions

Interview reports that mention this question

  • PeopleStrong SDE OA and Interview Questions: 12 Experiences
All PeopleStrong interview questionsSee PeopleStrong hiring insights
Saved
class Solution {
    public int[] maxSlidingWindow(int[] nums, int k) {
        // Write your solution here.
    }
}
Checking account…