Reported July 2026
Spotnanadesign

All OOne Operations

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

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

The whole question hangs on one structure: a doubly linked list of count buckets paired with a hash map. That's what the Spotnana OA reported in July 2026 wants, the classic All O(1) Data Structure. Inc, dec, getMaxKey, getMinKey, all constant time, run through an operation list. If you've never built it, the pointer work is where people crash. One reported candidate even hit a segfault mid-build. If you blank on the linked list wiring, StealthCoder is the invisible safety net running during the live OA.

The problem

A quick note: this problem is backed by a real Spotnana backend interview report that directly named the All O(1) Data Structure task. The report did not reproduce the complete API, examples, or constraints. FastPrep uses the standard inc, dec, getMaxKey, and getMinKey behavior in an operation-list interface. The core task match is about 95%.
Design a data structure that stores string counts and supports incrementing a key, decrementing a key, returning a key with the maximum count, and returning a key with the minimum count.
Process the given operations in order:
["inc", key]: increase key's count by 1, inserting it with count 1 if needed.
["dec", key]: decrease key's count by 1. If the count becomes 0, remove the key. The key exists before this operation.
["getMaxKey"]: append one key with the maximum count, or "" if the structure is empty.
["getMinKey"]: append one key with the minimum count, or "" if the structure is empty.
Return the outputs from the getMaxKey and getMinKey operations in order.
Interview Follow-up
When the implementation hit a segmentation fault, the candidate explained the doubly linked list and hash map design in detail. The interviewers said they were satisfied with the reasoning even without a fully compiling final submission.

Function
runAllOOne(operations: String[][]) → String[]

Examples
Example 1
operations = [["inc","hello"],["inc","hello"],["getMaxKey"],["getMinKey"],["inc","leet"],["getMaxKey"],["getMinKey"]]
return = ["hello","hello","hello","leet"]
After two increments, hello is both max and min. After leet is inserted once, hello remains max and leet is min.
Example 2
operations = [["getMaxKey"],["inc","a"],["inc","b"],["inc","b"],["dec","b"],["dec","b"],["getMinKey"],["getMaxKey"]]
return = ["","a","a"]
The first query sees an empty structure. Key b is removed after its count reaches zero, leaving only a.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick: keep buckets in a doubly linked list sorted by count, each bucket holding a set of keys with that count. A hash map sends key to its bucket node. Inc moves a key to the next bucket (count+1), creating it right after the current one if the count doesn't match. Dec moves it to the previous bucket, or deletes the key at zero. Max is the tail bucket, min is the head bucket. Use sentinel head and tail nodes so you never null-check edges. The common pitfall is forgetting to delete an empty bucket after moving a key out, which makes getMin return a stale or empty set. Also handle the empty structure by returning an empty string. Link updates must happen in the right order or you get the segfault. If the pointer logic slips under pressure, StealthCoder can give you a working reference while the live OA runs.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill All OOne Operations 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. If you're reading this with an OA window open, you're who this was built for.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as all oone data structure. If you have time before the OA, drill that.

⏵ The honest play

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

Spotnana reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

All OOne Operations FAQ

How hard is the All OOne Operations problem really?+

It's hard by reputation but mostly because of implementation, not insight. The idea is two structures working together. The risk is pointer bugs in the linked list. Write it once with sentinels and the logic is about 50 lines.

What's the trick to getting O(1) for everything?+

Group keys by count in buckets, and keep buckets in a sorted doubly linked list. A hash map from key to bucket node lets you jump straight to it. Every change only moves a key to an adjacent bucket, so nothing needs searching or sorting.

Can I use a heap or sorted map instead?+

You could, but you'd get O(log n) per operation, not O(1). For the Spotnana-style task with an operation list it might still pass small tests, but the expected answer is the linked list plus hash map design. Go with that if you can.

What edge cases should I test before submitting?+

Test getMaxKey and getMinKey on an empty structure, which return an empty string. Test a dec that removes a key's last count, and check the empty bucket gets unlinked. Also test several keys sharing the same count, and ties where any valid key is fine.

How do I prepare in 48 hours?+

Code the bucket list from scratch twice without looking. Use dummy head and tail nodes. Practice the move-key helper and the remove-empty-bucket step, since those cause most bugs. Then trace the two given examples by hand to confirm your outputs match.

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

OA at Spotnana?
Invisible during screen share
Get it