← Back to experiences
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/experiences/…$
Level: Mid-Level
Round: Phone Screen · Type: Coding · Difficulty: 4/10 · Duration: 60 min · Interviewer: Unfriendly
Topics: Data Structures, System Design
Location: San Francisco Bay Area
Interview date: 2025-08-01
Question: Design a simplified browser history system.
The phone screen question was a commonly asked interview question:
Design a simplified browser history system that supports the following operations:
visit(url: string)
Visit a new URL from the current page.
When this happens, all forward history should be cleared.back(steps: int) -> string
Move backward in history by up to steps.
Return the current page after moving back.
If you can’t move steps times because you reach the beginning of history, stop at the first page.forward(steps: int) -> string
Move forward in history by up to steps.
Return the current page after moving forward.
If you can’t move steps times because you reach the end of history, stop at the last page.You should implement a class BrowserHistory that initializes with a homepage and supports these methods.
Bonus:
hasVisited method to determine if a URL has been visited.