Python sol by deque [w/ Comment]
Python sol by deque\n\n---\n\nImplementation by deque:\n\n\nfrom collections import deque\n\nclass BrowserHistory:\n\n    def __init__(self, homepage: str):\n\t
Python sol by deque\n\n---\n\n**Implementation** by deque:\n\n```\nfrom collections import deque\n\nclass BrowserHistory:\n\n    def __init__(self, homepage: str):\n\t\n        self.history = deque([homepage])\n        self.cur_index = 0\n\n        \n        \n    def visit(self, url: str) -> None:\n        \n        # clear all forward history\n        tail_len = len(self.history)-1-self.cur_index\n        while tail_len:\n            self.history.pop()\n            tail_len -= 1\n            \n        self.history.append(url)\n        self.cur_index += 1\n\n        \n        \n    def back(self, steps: int) -> str:\n        \n\t\t# boundary check\n        if steps > self.cur_index:\n            self.cur_index = 0\n        else:\n            self.cur_index -= steps\n            \n        return self.history[self.cur_index]\n\n    \n    \n    def forward(self, steps: int) -> str:\n        \n\t\t# boundary check\n        if steps >= len(self.history) - self.cur_index:\n            self.cur_index = len(self.history) - 1\n        else:\n            self.cur_index += steps\n        \n        return self.history[self.cur_index]\n```\n\n---\n\nReference:\n\n[1] [Python official docs about deque( ... )](https://docs.python.org/3.8/library/collections.html#collections.deque)
['Queue', 'Iterator', 'Python', 'Python3']