C++✅✅ | Using Vectors🆗 | Beginner Friendly Approach🔥 | Clean Code |
PLEASE DO UPVOTE!!!!!!\n\n# Code\n\nclass BrowserHistory {\npublic:\n\nvector<string>v;\nint curr, cnt = 0;\n    BrowserHistory(string homepage) {\n     \n     
# PLEASE DO UPVOTE!!!!!!\n\n# Code\n```\nclass BrowserHistory {\npublic:\n\nvector<string>v;\nint curr, cnt = 0;\n    BrowserHistory(string homepage) {\n     \n        v.push_back(homepage);\n        curr = 0;\n    }\n    \n    void visit(string url) {\n     \n      curr++;\n      v.resize(curr);\n      v.push_back(url); \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     int n = v.size();\n     curr = min(n-1, curr+steps);\n\n     return v[curr];\n    }\n};\n\n```
['C++']