Beats 100% O(n) 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$$O(n)$$\n\n- Space complexity:\n$$O(n)$$\n\n# Code\n```typescript []\nfunction lastVisitedIntegers(nums: number[]): number[] {\n    let seen = []\n    let ans = []\n    let k = 0;\n    for(let i = 0; i < nums.length; i++) {\n        if(nums[i] === -1) {\n            k++;\n            if(k > seen.length) ans.push(-1)\n            else ans.push(seen[k - 1])\n        } else {\n            seen.unshift(nums[i])\n            k = 0;\n        }\n    }\n    \n    return ans\n};\n```
['TypeScript', 'JavaScript']