Resizable Array-Backed Integer Set
Reported by candidates from Disney's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Disney's September 2026 OA hands you a set with no hashing allowed, and the edge case that breaks a naive solution is hiding in the capacity rules. It's a simulation problem on a plain array. Add, remove, contains, size, capacity, and every command returns a string. The logic is easy. The order of the resize checks is where people lose points. If you've got an invite and 48 hours, read the resize rules twice before you write a line. StealthCoder sits invisibly on your screen as a safety net if you blank mid-assessment, but the rules below should get you most of the way.
The problem
Implement a set without hashing by storing unique integers in a contiguous array. Process commands ADD value, REMOVE value, CONTAINS value, SIZE, and CAPACITY. Every command emits a string result: mutations and membership emit true/false; SIZE and CAPACITY emit a decimal integer. The backing capacity starts at initialCapacity, doubles before inserting into a full array, and halves after removal when size is at most one quarter of capacity, never below the initial capacity. Preserve the relative order of remaining values. Function dynamicArraySet(operations: String[], initialCapacity: int) → String[] Examples Example 1 operations = ["ADD 4","ADD 7","ADD 4","CONTAINS 7","SIZE","CAPACITY"] initialCapacity = 2 return = ["true","true","false","true","2","2"] Duplicate insertion fails and capacity remains two. Example 2 operations = ["ADD 1","ADD 2","ADD 3","CAPACITY","REMOVE 2","REMOVE 3","CAPACITY"] initialCapacity = 2 return = ["true","true","true","4","true","true","2"] The third insert grows to four; size one then triggers shrink to two. Example 3 operations = ["REMOVE 9","CONTAINS 9","SIZE","CAPACITY"] initialCapacity = 3 return = ["false","false","0","3"] Missing removal is harmless and capacity never falls below its initial value. Constraints 1 <= initialCapacity <= 10^4. 1 <= operations.length <= 10^4. Values are signed 32-bit integers and commands are valid.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is that this is pure simulation. Keep an array of unique values, a capacity integer, and the initial capacity. ADD scans for the value. If it's found, return false. If the array is full (size equals capacity), double capacity first, then append. REMOVE scans, deletes while preserving order, then checks if size <= capacity / 4. If so, halve capacity, but never below initialCapacity. The common pitfall is shrink timing and integer division. Example 2 shows it: capacity 4, size 1, shrink to 2. Another trap is shrinking on a failed remove, which Example 3 rules out. Also don't double on a duplicate add, since Example 1 keeps capacity at two. Linear scans are fine at 10^4 operations. Don't reach for a hash set, the problem bans it in spirit. If you freeze on the edge cases, StealthCoder can give you a working reference during the live OA.
If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.
You can drill Resizable Array-Backed Integer Set 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. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Disney's OA.
Disney reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Resizable Array-Backed Integer Set FAQ
How hard is the Disney resizable array set problem really?+
Easy on algorithms, medium on care. There's no clever data structure. You lose points on resize conditions: when to double, when to halve, and the floor at initialCapacity. Trace all three examples by hand before submitting.
What's the trick to this problem?+
Treat it as a simulation with strict ordering. Check for duplicates first, then grow if full, then insert. On removal, delete first, then check size <= capacity / 4 and halve with the initial capacity as a floor.
Do I need a hash set or a faster lookup?+
No. The problem says no hashing, and with up to 10^4 operations a linear scan per command is fast enough. Worst case is around 10^8 simple comparisons only if every op scans a huge array, and in practice it's well within bounds.
Does a failed ADD or REMOVE change capacity?+
No. A duplicate ADD returns false and leaves capacity alone. A REMOVE of a missing value returns false and shouldn't trigger a shrink check. Example 3 confirms capacity stays at its initial value.
How do I prepare for this in 48 hours?+
Write the solution once from scratch, then run the three examples by hand. Add your own tests: shrink exactly at the quarter boundary, repeated grow and shrink cycles, and initialCapacity of 1. Remember to return every result as a string.