Design Browser History (#1472)
You have a browser of your own. You start on the homepage
, and you can visit
a new URL, move back
and forward
in history.
Implement the BrowserHistory
class:
BrowserHistory(string homepage)
Initializes the object with thehomepage
of the browser.void visit(string url)
Visitsurl
from the current page. It clears up all the forward history.string back(int steps)
Movesteps
back in history. If you can only returnx
steps in the history andsteps > x
, you will return onlyx
steps. Return the current URL after moving back in history at moststeps
.string forward(int steps)
Movesteps
forward in history. If you can only forwardx
steps in the history andsteps > x
, you will forward onlyx
steps. Return the current URL after forwarding in history at moststeps
.
Company Tags: Amazon
Core Concept: Array, Linked List, Stack