Your question is Browser History With Overwrite. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Implement browser history navigation for a Chime web surface. The history starts with a homepage, and each action changes the current page or navigates through existing history.
A visit action opens a new URL. When this happens, every page currently reachable through back is discarded. A back action moves backward by up to steps pages, stopping at the oldest retained page. A forward action moves forward by up to steps pages, stopping at the newest retained page.
Return the current URL after every action, in order.
Implement browser_history(homepage, actions):
homepage is a non-empty string.actions is a list of commands. Each command is either ['visit', url], ['back', steps], or ['forward', steps].steps is a positive integer for navigation commands.def browser_history(homepage, actions):