MEDIUMasked at 4 companies

Stock Price Fluctuation

A medium-tier problem at 48% community acceptance, tagged with Hash Table, Design, Heap (Priority Queue). Reported in interviews at MongoDB and 3 others.

Founder's read

Stock Price Fluctuation is a medium-difficulty data structure design problem that's come up at MongoDB, Ripple, Atlassian, and Mixpanel. The catch is that you're not just storing prices, you're maintaining the current price for a stock symbol while also tracking the maximum and minimum prices you've seen for that symbol across all updates. The naive approach fails hard on the efficiency side, and the pattern isn't obvious without knowing the right tool. With a 48% acceptance rate, this one catches people who think they can wing it with a basic hash table.

Companies asking
4
Difficulty
MEDIUM
Acceptance
48%

Companies that ask "Stock Price Fluctuation"

If this hits your live OA

Stock Price Fluctuation is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made for the engineer who has done the work but might still blank with a webcam pointed at him.

Get StealthCoder
What this means

The trick here is combining multiple data structures. A hash table gets you O(1) lookups for the current price, but tracking min and max efficiently as prices stream in requires a heap or ordered set on top of that. Many candidates try to maintain separate min/max variables and get wrecked when prices jump around. The real insight is that you need to keep a dynamic ordered collection of all prices you've ever seen for each symbol, not just the current one. Heaps work, but a balanced tree or sorted container is cleaner because you're querying extremes constantly. If this problem hits your live OA and you blank on the multi-structure approach, StealthCoder surfaces a working solution in seconds invisible to the proctor.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Stock Price Fluctuation recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made for the engineer who has done the work but might still blank with a webcam pointed at him. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Stock Price Fluctuation interview FAQ

Do I really need a heap for this, or will a hash table plus sorted list work?+

Hash table alone is too slow for min/max queries. A heap or ordered set (balanced tree) is required to stay efficient. Some languages have built-in ordered containers like TreeMap in Java or SortedDict in Python. The ordered set approach is often cleaner than dual heaps because you avoid the stale-element problem.

Is this still asked at places like MongoDB and Atlassian?+

Yes. It appears in the input data for both. This is a classic system design interview problem that tests whether you understand when a single data structure isn't enough and how to compose them. Companies building real data systems ask it.

What's the real gotcha when I code this live?+

Forgetting that you need to track all prices ever seen, not just the current one. If you only keep the current price and update a min/max, you'll fail when prices fluctuate up and down. You have to maintain a collection of historical prices per symbol and query it efficiently.

How does this relate to the Data Stream topic?+

Data Stream problems require you to handle incoming data in real time without storing the entire history inefficiently. Here, prices arrive sequentially, and you must answer queries about extremes on the fly. That's the stream constraint. Hash Table and Ordered Set are your tools to make it O(log n) per operation.

Will this problem be harder or easier than other medium-level design problems I've seen?+

The 48% acceptance rate suggests it's on the harder side of medium. A lot of candidates miss the multi-structure insight or implement it inefficiently. If you've drilled balanced trees or heap operations, you'll have an edge. If not, it's a tricky pattern to spot under pressure.

Want the actual problem statement? View "Stock Price Fluctuation" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.