O(n)
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```\nclass Solution:\n    def lastVisitedIntegers(self, nums: List[int]) -> List[int]:\n        seen=[]\n        ans=[]\n        k=1\n        for n in nums:\n            if n==-1:\n                if k<=len(seen):\n                    ans.append(seen[k-1])\n                else:\n                    ans.append(-1)    \n                k=k+1\n            if n>0:\n                seen=[n]+seen  \n                k=1 \n            print(seen)     \n        return ans        \n\n\n        \n```
['Python3']