Complete Explanation with Example || Simple Code || Easy to understand
\n\n\n\n\n\n\nclass BrowserHistory {\npublic:\n    vector<string>v;\n    int end, curr;\n    BrowserHistory(string homepage) \n    {\n        v.push_back(homepa
![image](https://assets.leetcode.com/users/images/c788fd4c-fab8-43e7-b1be-86845b325525_1679105036.9774773.png)\n![image](https://assets.leetcode.com/users/images/0c3c9938-db97-41ac-a2d7-dc84e1e542d3_1679105045.0978954.png)\n![image](https://assets.leetcode.com/users/images/fab88e9f-1392-456a-8772-583204997519_1679105052.9633954.png)\n\n\n\n```\nclass BrowserHistory {\npublic:\n    vector<string>v;\n    int end, curr;\n    BrowserHistory(string homepage) \n    {\n        v.push_back(homepage);\n        end = 0; curr = 0;\n    }\n    \n    void visit(string url) \n    {\n        if (curr == end)\n        {\n            if (end == v.size() - 1) { v.push_back(url); end++; } //push the new url, mark the end at end of array\n            else v[++end] = url; //increment end and then add the url there \n            curr++;  //increment curr\n        }\n        else \n        {\n            v[++curr] = url; //increment curr then add url there\n            end = curr; //rest all url\'s next to curr need to be erased, so simply mark end = curr;\n        }\n    }\n    \n    string back(int steps) \n    {\n        curr = max(0, curr - steps);\n        return v[curr];\n    }\n    \n    string forward(int steps)\n    {\n        curr = min(end, curr + steps);\n        return v[curr];\n    }\n};\n```
['C', 'C++']