Most Beginner Approach || yet O(n) || 50% T.C || 78% S.C || CPP
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    vector<int> lastVisitedIntegers(vector<int>& v) {\n        vector<int>p,a;\n        int k=-1;\n        for(auto i:v){\n            if(i!=-1){\n                p.push_back(i);\n                k=p.size()-1;\n            }\n            else if(i==-1&&k>-1){\n                a.push_back(p[k]);\n                k--;\n            }\n            else if(i==-1&&k==-1)   a.push_back(-1);\n        }\n        return a;\n\n// if my code helped you then please UpVOTE me, an UpVOTE encourages me to bring some more exciting codes for my coding family. Thank You o((>\u03C9< ))o\n    }\n};\n```
['C++']