Reported December 2023
Bloombergdesign

Design 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 December 2023 hands you a browser with a homepage and a list of commands, and the whole thing hinges on one data structure choice. It's Design Browser History, wrapped in a function that returns only the back and forward results. Visit commands print nothing, which trips people who expect output per line. If you've got an invite and 48 hours, this is a pattern you can lock down fast. An array with a pointer does the job. StealthCoder sits invisibly on your screen as a safety net if you blank during the live OA, but the logic here is small enough to own.

The problem

Start a browser on homepage and process commands:
visit url: navigate to url and discard all forward history.
back steps: move back up to steps entries and append the resulting URL.
forward steps: move forward up to steps entries and append the resulting URL.
Visit commands produce no output. Return results of back and forward commands in order.

Function
browserHistory(homepage: String, operations: String[]) → String[]

Examples
Example 1
homepage = "leetcode.com"
operations = ["visit google.com","visit facebook.com","visit youtube.com","back 1","back 1","forward 1","visit linkedin.com","forward 2","back 2","back 7"]
return = ["facebook.com","google.com","facebook.com","linkedin.com","google.com","leetcode.com"]
The LinkedIn visit discards the prior YouTube forward branch.

Constraints
1 <= operations.length <= 10^4.
URLs are nonempty and step counts are positive integers.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is an array plus a current index, not two stacks and not a linked list. Keep a list of URLs and a pointer. Visit: truncate everything after the pointer, append the URL, move the pointer to the end. Back: pointer = max(0, pointer - steps). Forward: pointer = min(last index, pointer + steps). Then append the URL at the pointer to your result. The common pitfall is forgetting to discard forward history on a visit, which breaks the LinkedIn step in the example. Another is forgetting to clamp, which the back 7 case tests. Parse each operation by splitting on the space and reading the integer for steps. With up to 10^4 operations, even slicing on every visit is fine, but truncating in place is cleaner. If your head goes blank mid-OA, StealthCoder is the hedge that reads the prompt and hands you this structure.

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 Design 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

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as design browser history. If you have time before the OA, drill that.

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

Design Browser History FAQ

How hard is the Bloomberg Design Browser History OA question really?+

Easy to medium. There's no clever algorithm, just clean state management. Most failures come from off-by-one clamping or forgetting that a visit wipes forward history. If you can write the pointer logic in ten minutes, you're fine.

What's the trick to solving it?+

Store URLs in an array with a current index. Visit truncates the array after the index and appends. Back and forward just move the index with clamping at 0 and the last element. Every operation is O(1) or amortized close to it.

Do visit commands add anything to the output?+

No. Only back and forward commands append the resulting URL to the returned list. In the example, ten operations produce six outputs because the three visits and one extra visit are silent. Count your outputs against that before submitting.

Should I use two stacks or an array?+

Either works, but the array with a pointer is simpler and has fewer bugs. Two stacks need you to clear the forward stack on visit and move items one by one for steps. The array lets you jump straight to the target index.

How do I prepare for this in 48 hours?+

Write it once from scratch without looking, then test the example by hand, especially the back 7 clamp and the visit after back case. Also practice parsing the operation strings. After that, spend your time on other design-style problems with similar state tracking.

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