Browser history

Write codeMedium20 minBloomberg and Google style

Your task

Simulate a browser's history starting at homepage. Replay operations: ["visit", url] navigates to url and clears any forward history; ["back", steps] moves back up to steps pages (stopping at the oldest) and returns the current url; ["forward", steps] moves forward up to steps pages (stopping at the newest) and returns the current url. Return the list of urls produced by every back and forward operation, in order.

Examples

browser_history(homepage: str, ops: list[list]) -> list[str]
Example 1
Inputbrowser_history("notebook.com", [["visit", "google.com"], ["visit", "facebook.com"], ["visit", "youtube.com"], ["back", 1], ["back", 1], ["forward", 1], ["visit", "linkedin.com"], ["forward", 2], ["back", 2], ["back", 7]])
Output["facebook.com", "google.com", "facebook.com", "linkedin.com", "google.com", "notebook.com"]