Easiest C++ Solution ?
\n# Code\n\nclass Solution {\npublic:\n    vector<int> lastVisitedIntegers(vector<string>& words) {\n        vector<int>v;\n        vector<int>ans;\n        int
\n# Code\n```\nclass Solution {\npublic:\n    vector<int> lastVisitedIntegers(vector<string>& words) {\n        vector<int>v;\n        vector<int>ans;\n        int count=0;\n        for(int i=0;i<words.size();i++){\n            if(words[i]=="prev"){\n                count++;\n                if(count>v.size()){\n                    ans.push_back(-1);\n                }\n                else{\n                    ans.push_back(v[v.size()-count]);\n                }\n            }\n            else{\n                count=0;\n                v.push_back(stoi(words[i]));\n            }\n        }\n        return ans;\n    }\n};\n\n```
['C++']