Easy Linked List Solution - 0(n) solution
Intiuition - Consider each website as a node which contains data to the next website and the pointer to it and pointer to the previous website.\nRest is like in
* **Intiuition** - Consider each website as a node which contains data to the next website and the pointer to it and pointer to the previous website.\nRest is like inserting in Linked list,deleting in Linked List ques.\nFor making the node use a class.\n\n**1. Time complexity - 0(steps) \n2. Space complexity - 0(N)**\n\n\n\nIf you like the solution pls upvote ;)\n\n\n\n   \n   \n    class Node{\n    public:\n    string data ; \n    Node* prev ; \n    Node* next ;\n    public:\n    Node(string data1,Node* prev1,Node* next1){\n        data = data1;\n        prev = prev1 ; \n        next = next1 ; \n    }\n    Node(string data1){\n        data = data1 ; \n        prev = NULL ; \n        next = NULL ; \n    }\n    };\n\n\n     class BrowserHistory {\n    public:\n    Node* atcurrent = NULL ; \n    BrowserHistory(string homepage) {\n        Node* newnode = new Node(homepage);\n         atcurrent = newnode ;\n     }\n    \n    void visit(string url) {\n        Node* temp = new Node(url);\n         temp->prev = atcurrent ; \n         atcurrent->next = temp ; \n         temp->next = NULL ; \n          atcurrent = temp;\n    }\n    \n    string back(int steps) {\n        Node* back = atcurrent ; \n        while(steps){\n            if(back->prev==NULL){\n                atcurrent = back ;\n                return back->data ; \n                break ;\n            }\n            back = back->prev ;\n            steps--;\n        }\n        atcurrent = back ; \n        return back->data ; \n    }\n    \n    string forward(int steps) {\n        Node* forward = atcurrent ;\n        while(steps){\n            if(forward->next==NULL){\n                atcurrent = forward ; \n                return forward->data ; \n                break ; \n            }\n            forward = forward->next ; \n            steps--;\n        }\n        atcurrent = forward ; \n        return forward->data ; \n    }\n     };\n
['Linked List', 'C']