A beginner friendly C++ Solution || Straight Forward approach
Code\ncpp []\nclass Solution {\npublic:\n    vector<int> lastVisitedIntegers(vector<int>& nums) {\n        vector<int> seen;\n        vector<int> ans;\n        
# Code\n```cpp []\nclass Solution {\npublic:\n    vector<int> lastVisitedIntegers(vector<int>& nums) {\n        vector<int> seen;\n        vector<int> ans;\n        int k = 0;\n        for(int i = 0;i<nums.size();i++)\n        {\n            if(nums[i] > 0)\n            {\n                seen.insert(seen.begin(),nums[i]);\n                k = 0;\n            }\n            else if(nums[i] == -1)\n            {\n                k++;\n                if(k<= seen.size())\n                {\n                    ans.push_back(seen[k-1]);\n                }\n                else if(k > 0)\n                {\n                    ans.push_back(-1);\n                }\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']