Easy JAVA Solution!
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:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n    public List<Integer> lastVisitedIntegers(int[] nums) {\n        List<Integer> seen = new ArrayList<>();\n        List<Integer> ans = new ArrayList<>();\n        int ct = 0;\n        for(int num : nums) {\n            if(num == -1) {\n                ct++;\n                if(ct <= seen.size()) {\n                    ans.add(seen.get(ct-1));\n                }\n                else {\n                    ans.add(-1);\n                }\n            }\n            else {\n                seen.add(0, num);\n                ct = 0;\n            }\n        }\n        return ans;\n    }\n}\n```
['Java']