Level: Senior-Level
Round: Phone Screen · Type: Coding · Difficulty: 6/10 · Duration: 60 min · Interviewer: Neutral
Topics: Data Structures, Algorithms, Browser History
Location: San Francisco Bay Area
Interview date: 2025-07-23
I had a phone screen with a coding question about implementing browser history functionality.
I was asked to implement a single-tab browser with back and forward functionality, starting from a homepage. The required functions were:
constructor(string homepage): Initializes the browser with the homepage.void visit(string url): Visits a URL, clearing the forward history.string back(int steps): Moves back in history by a given number of steps.string forward(int steps): Moves forward in history by a given number of steps.I was also presented with bonus questions:
bool haveVisited(string url): Checks if a URL has been visited.` constructor(string homepage) Initializes the object with the homepage of the browser.
void visit(string url) Visits url from the current page. It clears up all the forward history.
string back(int steps) Move steps back in history. If you can only return x steps in the history and steps > x, you will return only x steps. Return the current url after moving back in history at most steps.
string forward(int steps) Move steps forward in history. If you can only forward x steps in the history and steps > x, you will forward only x steps. Return the current url after forwarding in history at most steps.
Bonus-1 bool haveVisited(string url) Indicates whether user has visited the particular url or not
Bonus-2 Implement the solution for multiple tabs `
I discussed the trade-offs between using a Map and a List for the multiple tabs implementation. I was not asked to write code for Bonus-2.