Reported September 2026
Agodahash table

Shortest Subarray With the Full Degree

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

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

The Agoda OA reported in September 2026 hinges on one data structure: a hash map. The problem is Shortest Subarray With the Full Degree, and it looks like a subarray search until you notice you never need to search at all. You're tracking three things per value: how often it shows up, where it first appeared, and where it last appeared. With the OA invite sitting in your inbox, that's the whole trick. One pass, a few maps, done. If your mind goes blank mid-assessment, StealthCoder runs invisibly as a safety net and hands you the solution while you keep typing.

The problem

The degree of an array is the largest frequency of any value. Return the length of the shortest contiguous subarray having the same degree as nums.

Function
findShortestSubarray(nums: int[]) → int

Examples
Example 1
nums = [1,2,2,3,1]
return = 2
Case 1 exercises the documented deterministic contract.
Example 2
nums = [1,2,2,3,1,4,2]
return = 6
Case 2 exercises the documented deterministic contract.
Example 3
nums = [1]
return = 1
Case 3 exercises the documented deterministic contract.

Constraints
1 <= nums.length <= 200000.
-10^9 <= nums[i] <= 10^9.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Build three hash maps in a single pass: count, first index, last index. Track the max frequency as you go. After the pass, loop over each value whose count equals the max degree and compute last - first + 1. Take the minimum. That's O(n) time and O(n) space, which matters with up to 200000 elements. The common pitfall is trying a sliding window or checking every subarray, which is quadratic and will time out. Another miss is forgetting ties: several values can share the max frequency, so you must compare all of them, not just the first. Example 2 shows this, where 2 appears three times and spans indices 1 to 6, giving 6. Negative values and large magnitudes are fine because a hash map doesn't care. If you freeze on the OA, StealthCoder is the hedge that surfaces this exact approach 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 Shortest Subarray With the Full Degree 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 degree of an array. If you have time before the OA, drill that.

⏵ The honest play

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

Agoda 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.

Shortest Subarray With the Full Degree FAQ

How hard is Shortest Subarray With the Full Degree really?+

Easy to medium. The idea is short once you see it, but candidates overthink it with windows or nested loops. If you know to store count, first index, and last index per value, it's maybe fifteen lines of code.

What's the trick for the Agoda OA version?+

Any subarray with the full degree must start at the first occurrence and end at the last occurrence of a max-frequency value. So you only need those two indices per value. Track them in a hash map during one pass, then minimize the span.

What's the time complexity I should aim for?+

O(n) time and O(n) space. With n up to 200000, anything quadratic is risky. One pass to fill the maps and one pass over the distinct values is all you need.

What edge cases should I test?+

A single element array returns 1. Arrays where every value is unique have degree 1, so the answer is 1. Ties between multiple max-frequency values need the minimum span. Also test negative numbers and large values like 10^9.

How do I prepare for this in 48 hours?+

Write this solution from scratch twice using a hash map. Then do two or three other frequency-and-index map problems so the pattern is automatic. Focus on handling ties and on avoiding brute force. You don't need more than that.

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

OA at Agoda?
Invisible during screen share
Get it