Reported August 2020
Bloombergdesign

Capacity-Bounded Browser History

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

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

The Bloomberg OA reported in August 2020 is a browser history question that really tests whether you pick the right data structure. You get parallel arrays of operations and URLs, plus a capacity. Visit moves a URL to most recent, evicts the oldest if you're over capacity, and clear wipes everything. It's an LRU cache in disguise, minus the values. If you've got an OA invite and a day or two, this is a pattern worth locking in. StealthCoder sits invisibly on your screen as a safety net if your mind goes blank mid-assessment.

The problem

Process parallel operations and urls for a browser history of at most capacity distinct URLs.
visit: remove the URL's older position if present, then make it most recent. If over capacity, evict the least recent URL.
clear: remove every URL; its matching urls value is ignored.
Return final distinct URLs from least recent to most recent.

Function
finalBoundedHistory(operations: String[], urls: String[], capacity: int) → String[]

Examples
Example 1
operations = ["visit","visit","visit","visit"]
urls = ["a","b","a","c"]
capacity = 2
return = ["a","c"]
Revisiting a makes it newest; visiting c then evicts b.

Constraints
Arrays have equal length.
0 <= capacity <= 10^5.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is an ordered structure with O(1) removal and O(1) move-to-end. In Python that's an OrderedDict, in Java a LinkedHashSet, or a hash map plus doubly linked list. On visit, delete the URL if present, append it, then if size exceeds capacity pop from the front. On clear, empty the structure and ignore the matching url value. The pitfalls are edge cases. Capacity 0 means the history is always empty, so evict right after inserting or skip the insert. Don't use a plain list with remove, because that's O(n) and can blow up near 10^5 operations. Also remember the output order is least recent to most recent, which is just iteration order. If you freeze on the linked structure during the live OA, StealthCoder is the hedge that surfaces the solution while the proctor sees nothing.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Capacity-Bounded Browser History 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 StealthCoder

Related leaked OAs

⏵ The honest play

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

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

Capacity-Bounded Browser History FAQ

What's the trick in the Bloomberg capacity-bounded browser history problem?+

Treat it as an LRU cache without values. Use an insertion-ordered set or map. On visit, remove the URL if it exists, re-add it at the end, and pop from the front if size exceeds capacity. Clear just empties the structure.

How hard is this problem really?+

Easy to medium. The logic is short once you recognize LRU behavior. Difficulty comes from picking a structure with O(1) delete and reinsert, and from handling edge cases like capacity 0 correctly.

What edge cases should I test?+

Capacity 0, which must always return an empty list. Revisiting the only URL. A clear followed by more visits. Clear operations where the matching URL value is junk or empty. Also check that revisiting an existing URL doesn't trigger an eviction when size stays within capacity.

What complexity do I need to hit?+

Aim for O(n) total time across all operations, with O(capacity) space. Capacity can reach 10^5, so a list with linear remove per visit risks O(n^2) behavior. A hash-backed ordered structure keeps each operation constant time.

How do I prepare for this in 48 hours?+

Write an LRU cache from scratch once using a hash map and doubly linked list, then redo it with your language's ordered map. Run the example by hand, including capacity 0 and clear. That covers this problem and its close variants.

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

OA at Bloomberg?
Invisible during screen share
Get it