2899. Last Visited Integers
\n\n# Complexity\n# - Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n# - Space complexity: O()\n Add your space complexity here, e.g. O(n)
\n\n# Complexity\n# **- Time complexity: O(n)**\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n# **- Space complexity: O()**\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python3 []\nclass Solution:\n    def lastVisitedIntegers(self, nums: List[int]) -> List[int]:\n        seen = []\n        ans = []\n        k = 0\n        for i in nums:\n            if i != -1:\n                seen.insert(0,i)\n                k = 0\n            else:\n                k += 1\n                if k <= len(seen):\n                    ans.append(seen[k-1])\n                else:\n                    ans.append(-1)\n        return ans\n```
['Python3']