[C++] Simple Solution
Code

# Code
```cpp []
class Solution {
public:
    vector<int> lastVisitedIntegers(vector<int>& A) {
        vector<int> ans;
        deque<int> seen;

        int k = 0;
        for(int i=0; i<A.size(); i++) {
            if(A[i] > 0) {
                seen.push_front(A[i]);
                k = 0;
            } else {
                k++;
                if(k <= (int)seen.size()) {
                    ans.push_back((int)seen.at(k-1));
                } else {
                    ans.push_back(-1);
                }
            }
        }
        return ans;
    }
};
```
['C++']