JAVA || DOUBLY LL. || EASY || FULL EXPLANATION || STRAIGHT FORWARD
Intuition\nEASY SOLUTION USING DOUBLEY LL.\n\n\n# Approach\n this problem is nothing but triversal of DLL\n such as -:\n\n FOR creating homepage - we initialize
# Intuition\nEASY SOLUTION USING DOUBLEY LL.\n\n\n# Approach\n this problem is nothing but triversal of DLL\n such as -:\n\n* FOR creating homepage - we initialize and create a head node , named head (it is fix)\n\n* VISIT - keep track of current tail node and add node(URL)accordingly\n\n* BACK - if step>size return node and update tail =head else triverse tail to steps and return that node(URL page)\n\n* FORWARD -  if step>size return tail else triverse upto step and return tail\n\n# Complexity\n- Time complexity:\nO(N+N)\n- Space complexity:\nO(N)\n\n# Code\n```\nclass BrowserHistory {\n    node head;\n    node tail;\n    int size;\n    public BrowserHistory(String homepage) {\n        node n =new node(homepage);\n        head = n;\n        tail = n;\n        size=1;\n    }\n    \n    public void visit(String url) {\n        tail.next =null;\n        size=size(head);\n        node nd = new node(url);\n        tail.next = nd;\n        nd.prev = tail;\n        tail = tail.next;\n        size++;\n    }\n    \n    public String back(int steps) {\n        if(steps>=size){\n            tail = head;\n        return head.data;\n        }\n\n        while(steps-->0 && tail.prev!=null){\n            tail = tail.prev;\n        }\n\n        return tail.data;\n    }\n    \n    public String forward(int steps) {    \n        while(steps-->0 && tail.next!=null){\n            tail = tail.next;\n        }\n        return tail.data;\n    }\n    \n    public int size(node head){\n        if(head==null)\n        return 0;\n        node temp = head;\n        int s =0;\n        while(temp!=null){\n            temp = temp.next;\n            s++;\n        }\n        return s;\n    }\n\n}\n\nclass node{\n    node next;\n    node prev;\n    String data;\n    node(String data){\n        this.data= 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```
['Java']