Design Browser History
Updated
Problem statement
Given a starting page homepage and a list of commands operations, return the page you land on after each back or forward command, in order. Visit commands add nothing to the result.
Each command is one of these:
visit url: go to url and clear all forward history.back steps: go back up to steps pages, stopping early if there is no earlier page.forward steps: go forward up to steps pages, stopping early if there is no later page.
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"]Visiting linkedin.com from facebook.com clears youtube.com from forward history, so the next forward command stays on linkedin.com. The last back command asks for more steps than exist, so it stops at leetcode.com.
Constraints
1 <= operations.length <= 10^4.- URLs are nonempty and step counts are positive integers.
More Bloomberg LP Phone Screen questions
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
- Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
- Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Sparse Vector and Matrix OperationsPHONE SCREEN · Seen Oct 2026
- Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Decode StringPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Random Dasher Set OperationsDoorDash · ONSITE INTERVIEWDoorDash interview questions
- Design Hit CounterCharta Health · PHONE SCREENCharta Health interview questions
- Round-Robin Iterator over IteratorsBridge · ONSITE INTERVIEWBridge interview questions
- Constant-Time Weighted Pick with an Alias TableEtched · PHONE SCREEN
- Billing Log with Undo and RedoReddit · PHONE SCREENReddit interview questions
- Portfolio Tickers with Constant-Time Random PickCitadel · PHONE SCREENCitadel interview questions
- Design Hit CounterNutanix · ONSITE INTERVIEWNutanix interview questions
- Top K Largest Values from a StreamThe D.E. Shaw Group · ONSITE INTERVIEWThe D.E. Shaw Group interview questions
- Count Events in Rolling Minute WindowsMeta · PHONE SCREENMeta interview questions
- Path Leaf Character IteratorGoogle · ONSITE INTERVIEWGoogle interview questions
Interview reports that mention this question
- Bloomberg SWE Intern Interview Questions: 68 Questions
- Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
- Bloomberg New Grad Question Bank: 161 Questions (Part 1 of 2)
- Bloomberg New Grad Interviews: 2025 vs 2026 Guide
- Bloomberg New Grad VOs: 32 Experiences (Part 5 of 5)
- Bloomberg New Grad Screens: 30 Experiences (Part 4 of 5)