Python3 Solution | Beats 100% | O(n) | Simplest ever |
Code
\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 range(0,len(nums)):\n            if nums[i]>0:\n                seen.insert(0,nums[i])\n                k=0\n            else:\n                k=k+1\n                print(k)\n                if k<=len(seen):\n                    ans.append(seen[k-1])\n                else:\n                    ans.append(-1)\n        return ans\n                \n\n```
['Python3']