✅ Double-Linked List || Super Easy Solution || Beginner Friendly || Easy to understand
Code\n\n// create a class "Node" for implementing double-linked list\nclass Node {  \npublic: \n    string data;\n    Node* next;\n    Node* prev;\n\n    Node()
# Code\n```\n// create a class "Node" for implementing double-linked list\nclass Node {  \npublic: \n    string data;\n    Node* next;\n    Node* prev;\n\n    Node() : data(0), next(nullptr), prev(nullptr) {};   // constructors\n    Node(string x) : data(x), next(nullptr), prev(nullptr) {};  // constructors\n}; \n\nclass BrowserHistory {\npublic:\n    Node* currentPage;\n\n    BrowserHistory(string homepage) {    // constructor\n        currentPage = new Node(homepage);\n    }\n    \n    void visit(string url) {\n        Node* newNode = new Node(url);\n        currentPage->next = newNode;\n        newNode->prev = currentPage;\n        currentPage = newNode;        \n    }\n    \n    string back(int steps) {\n        while(steps != 0){\n            if(currentPage->prev)\n                currentPage = currentPage->prev;\n            else\n                break;\n            \n            steps--;\n        }\n        return currentPage->data;\n    }\n    \n    string forward(int steps) {\n        while(steps != 0){\n            if(currentPage->next)\n                currentPage = currentPage->next;\n            else\n                break;\n            \n            steps--;\n        }\n        return currentPage->data;\n    }\n};\n\n/**\n * Your BrowserHistory object will be instantiated and called as such:\n * BrowserHistory* obj = new BrowserHistory(homepage);\n * obj->visit(url);\n * string param_2 = obj->back(steps);\n * string param_3 = obj->forward(steps);\n */\n```\n\n\n![Leetcode Upvote.jpeg](https://assets.leetcode.com/users/images/6e3c2c4c-b918-4601-a706-15e67baf41a0_1706299289.8183873.jpeg)\n
['Linked List', 'Doubly-Linked List', 'C++']