Easy Java solution-
Code

# Code
```java []
class Solution {
    public List<Integer> lastVisitedIntegers(int[] nums) {
        List<Integer> seen=new ArrayList<>(),ans=new ArrayList<>();
        int k=1;
        for(int x:nums){
            if(x>0){
                seen.add(0,x);
                k=1;
            }
            else{
                if(k<=seen.size())ans.add(seen.get(k-1));
                else ans.add(-1);
                k++;
            }
        }
        return ans;
    }
}
```
['Java']