C++ | Doubly Linked List | Clean and Concise
\nclass Node\n{\n    public:\n    string data;\n    Node *prev,*next;\n    \n    Node()\n    {\n        data="";\n        prev=next=NULL;\n    }\n    Node(strin
```\nclass Node\n{\n    public:\n    string data;\n    Node *prev,*next;\n    \n    Node()\n    {\n        data="";\n        prev=next=NULL;\n    }\n    Node(string _data)\n    {\n        data=_data;\n        prev=next=NULL;\n    }\n};\nclass BrowserHistory {\npublic:\n    \n    Node *curr=new Node();\n    BrowserHistory(string homepage) {\n        Node *begin=new Node(homepage);\n        begin->prev=curr;\n        curr->next=begin;\n        curr->prev=NULL;\n        curr=curr->next;\n        \n    }\n    \n    void visit(string url) {\n        Node *newNode=new Node(url);\n        curr->next=newNode;\n        newNode->prev=curr;\n        newNode->next=NULL;\n        curr=curr->next;\n    }\n    \n    string back(int steps) {\n        \n        while(steps-- and curr->prev->data!="")\n        {\n            curr=curr->prev;\n\t\t}\n        return curr->data;\n    }\n    \n    string forward(int steps) {\n        \n        while(steps-- and curr->next)\n        {\n            curr=curr->next;\n        }\n        return curr->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**Pls upvote if you found helpful.**
['Linked List', 'C', 'C++']