Python - 3 Easy Solutions (Array, Doubly Linked List) - O(1)
Approach\n1. Doubly Linked List \n2. Array\n3. Array Optimised\n\n# Code - Doubly Linked List Solution\n\nclass ListNode:\n    def __init__(self, val = "", next
# Approach\n1. Doubly Linked List \n2. Array\n3. Array Optimised\n\n# Code - Doubly Linked List Solution\n```\nclass ListNode:\n    def __init__(self, val = "", next = None, prev = None):\n        self.val = val\n        self.next = next\n        self.prev = prev\n\nclass BrowserHistory:\n    # Space O(number_of_pages_visited)\n    def __init__(self, homepage: str):\n        self.current_page = ListNode(val=homepage)\n        \n    # Time O(1)\n    def visit(self, url: str) -> None:\n        if self.current_page.next:\n            self.current_page.next.prev = None\n        self.current_page.next = ListNode(val=url, prev=self.current_page)\n        self.current_page = self.current_page.next\n        \n    # Time O(steps)\n    def back(self, steps: int) -> str:\n        while self.current_page.prev and steps > 0:\n            steps -= 1\n            self.current_page = self.current_page.prev\n        return self.current_page.val\n\n    # Time O(steps)\n    def forward(self, steps: int) -> str:\n        while self.current_page.next and steps > 0:\n            steps -= 1\n            self.current_page = self.current_page.next\n        return self.current_page.val\n```\n# Code - Array \n```\nclass BrowserHistory:\n    # Space O(number_of_pages_visited)\n    def __init__(self, homepage: str):\n        self.array = [homepage]\n        self.cur_page_pointer = 0  \n\n    # Time O(n) - Apparently del is O(n)\n    def visit(self, url: str) -> None:\n        if self.cur_page_pointer < len(self.array)-1:\n            del self.array[self.cur_page_pointer+1:]\n        self.array.append(url)\n        self.cur_page_pointer += 1\n        \n    # Time O(1)\n    def back(self, steps: int) -> str:\n        self.cur_page_pointer = max(0, self.cur_page_pointer - steps)\n        return self.array[self.cur_page_pointer]\n        \n\n    # Time O(1)\n    def forward(self, steps: int) -> str:\n        self.cur_page_pointer = min(len(self.array)-1, self.cur_page_pointer + steps)\n        return self.array[self.cur_page_pointer]\n```\n# Code - Array Optimised\nTime O(1) - Achieved through writing over discarded values\n```\nclass BrowserHistory:\n    # Space O(number_of_pages_visited)\n    def __init__(self, homepage: str):\n        self.array = [homepage]\n        self.cur_page_pointer = 0  \n        self.cur_boundary = 0\n\n    # Time O(1)\n    def visit(self, url: str) -> None:\n        self.cur_page_pointer += 1\n        if self.cur_page_pointer == len(self.array):\n            self.array.append(url)\n        else:\n            self.array[self.cur_page_pointer] = url\n        self.cur_boundary = self.cur_page_pointer\n        \n    # Time O(1)\n    def back(self, steps: int) -> str:\n        self.cur_page_pointer = max(0, self.cur_page_pointer - steps)\n        return self.array[self.cur_page_pointer]\n        \n\n    # Time O(1)\n    def forward(self, steps: int) -> str:\n        self.cur_page_pointer = min(self.cur_boundary, self.cur_page_pointer + steps)\n        return self.array[self.cur_page_pointer]\n\n```
['Array', 'Doubly-Linked List', 'Python', 'Python3']