Easy Beats 100.00% 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:\nO(n)\n\n- Space complexity:\nO(n)\n\n# Code\n```java []\nclass Solution {\n    public List<Integer> lastVisitedIntegers(int[] nums) {\n\n        List<Integer> ans = new ArrayList<>(), seen = new ArrayList<>();\n        int k = 0;\n\n        for (int num : nums)\n            if (num >= 0) {\n                seen.add(0, num);\n                k = 0;\n            } else if (seen.size() >= ++k) {\n                ans.add(seen.get(k - 1));\n            } else {\n                ans.add(-1);\n            }\n\n        return ans;\n    }\n}\n```
['Java']