✅✅C++ || Easy Solution || 💯💯Vector Approach || Heavily Commented
\u2705\u2705C++ || Easy Solution || \uD83D\uDCAF\uD83D\uDCAFVector Approach || Heavily Commented\n# Please Upvote as it really motivates me\n\n\n\nclass Browser
## **\u2705\u2705C++ || Easy Solution || \uD83D\uDCAF\uD83D\uDCAFVector Approach || Heavily Commented**\n# **Please Upvote as it really motivates me**\n\n```\n\nclass BrowserHistory {\n\t//we are creating a vector of strings to store the url string \n    vector<string>list;\n\t//idx will show on which index of vector are we on\n    int idx=-1;\n\t//the maxSize is used to store the maximum size of the vector \n\t\t//it contain size of the possible vector \n    int maxSize=0;\npublic:\n//In BrowserHistory we will simply initialize our vector and idx to 0 and maxSize to one\n    BrowserHistory(string homepage) {\n        list.push_back(homepage);\n        idx=0;\n        maxSize=1;\n    }\n    //when we are visiting a url we can have two options\n\t\t//1. if we are not on the end of list.size() i.e. idx<list.size()-1\n\t\t\t//then we will simply put the url at next index and increase idx and also update maxSize to idx+1\n\t\t//2. else we are on the end of vector we will have to push back to the vector and the both idx and maxSize increase by one\n    void visit(string url) {\n\t//First condition\n        if(list.size()-1>idx){\n            list[idx+1]=url;\n            idx++;\n            maxSize=idx+1;\n        }\n\t\t//2nd condition\n        else{\n            list.push_back(url);\n            idx++;\n            maxSize++;\n        }\n    }\n    \n    string back(int steps) {\n\t\t//we will find the val to which we can go back\n        int val=min(steps,idx);\n\t\t//substract from the idx\n        idx-=val;\n\t\t//return the list[idx]\n        return list[idx];\n    }\n    \n    string forward(int steps) {\n\t\t//we will find the val to which we can go back\n        int val=min(steps,maxSize-idx-1);\n\t\t//add from the idx\n        idx+=val;\n\t\t//return the list[idx]\n        return list[idx];\n    }\n};\n\n```\n\n![image](https://assets.leetcode.com/users/images/7f423b57-81a2-46ce-9ab2-72ad38f668f7_1675480558.466273.png)\n
['C', 'C++']