100% Beat Runtime
Intuition\n Describe your first thoughts on how to solve this problem. \n\n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Tim
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n![image.png](https://assets.leetcode.com/users/images/95202a4c-7349-486b-b15b-61225c07780e_1724447960.073004.png)\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```python []\nclass Solution(object):\n    def lastVisitedIntegers(self, nums):\n        seen = []\n        ans = []\n        k = -1\n        for n in nums:\n            if n != -1:\n                k = -1\n                seen.append(n)\n            elif len(seen) >= -k:\n                ans.append(seen[k])\n                k -= 1\n            else:\n                ans.append(-1)\n                k -= 1\n        return ans\n        \n```
['Array', 'Simulation', 'Python', 'Python3']