Easiest but not fastest || C++ Solution
Code
# Code
```cpp []
class Solution {
public:
    vector<int> lastVisitedIntegers(vector<int>& nums) {
        deque<int> seen;
        vector<int> ans;
        int ptr=0;
        for(int i: nums){
            if(i!=-1){
                seen.push_front(i);
                ptr=0;
            }
            else if(ptr<seen.size()){
                ans.push_back(seen[ptr]);
                ptr++;
            }
            else{
                ans.push_back(-1);
            }
        }
        return ans;
    }
};
```
['C++']