Reported September 2026
Growwsliding window

Sliding Window Maximum

Reported by candidates from Groww's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Groww OA. Under 2s to a working solution.
Founder's read

Groww reportedly put Sliding Window Maximum in front of candidates in September 2026, and the constraint is the whole story: nums can hit 100000 elements, so scanning every window of size k costs O(n*k) and dies when k is large. You need O(n). The pattern is a sliding window backed by a monotonic deque. If you've seen it once, it's a ten-minute problem. If you haven't, it's a wall. StealthCoder sits invisibly on your screen during the live OA as a safety net if your mind goes blank on the deque logic.

The problem

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 = 3
return = [3,3,5,5,6,7]
Each output is the largest value in the corresponding length-three window.
Example 2
nums = [1]
k = 1
return = [1]
The only window contains the only value.
Example 3
nums = [9,8,7,6]
k = 2
return = [9,8,7]
In a decreasing array, each window maximum is its leftmost value.

Constraints
1 <= nums.length <= 100000
-1000000000 <= nums[i] <= 1000000000
1 <= k <= nums.length

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is a deque of indices whose values are kept in decreasing order. For each new index i, pop from the back while nums[back] <= nums[i], since those can never be a max again. Push i. Then pop from the front if the front index is <= i - k, because it left the window. Once i >= k - 1, the front of the deque is your answer for that window. Every index enters and leaves once, so it's O(n). Common pitfalls: storing values instead of indices, so you can't tell when the front expires. Also off-by-one on the expiry check, and starting output too early. Example 3 (decreasing array) is a good test, since the deque keeps everything. A heap works in O(n log n) with lazy deletion, but the deque is cleaner. If the deque invariant slips from memory mid-assessment, StealthCoder can hand you the working solution live.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Sliding Window Maximum cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as sliding window maximum. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Groww's OA.

Groww reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Sliding Window Maximum FAQ

How hard is Sliding Window Maximum really?+

It's a LeetCode Hard, but the solution is short once you know the monotonic deque. The difficulty is in seeing it. The code is about 12 lines. Candidates who've never met the deque idea usually get stuck at brute force or a heap.

What's the trick for the Groww version?+

Keep a deque of indices with decreasing values. Pop smaller values from the back before pushing the new index, pop expired indices from the front, and read the max from the front. Each element is touched at most twice, giving O(n).

Will brute force pass with n up to 100000?+

Probably not. Checking every window costs O(n*k), and with k near n/2 that's billions of operations. The constraints are a signal that you need linear or n log n. Don't waste your time coding brute force first.

Can I use a heap instead of a deque?+

Yes. Push (value, index) into a max-heap and pop the top while its index is outside the window. It runs in O(n log n), which fits the limits. It's a decent fallback if you forget the deque, though the deque is the expected answer.

How do I prepare in 48 hours?+

Write the deque solution from scratch twice, then trace Example 1 by hand. Test edge cases: k = 1, k = n, and a strictly decreasing array. Also review the related sliding window patterns so the index-expiry logic feels automatic.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Groww.

OA at Groww?
Invisible during screen share
Get it