Python 3 | Beats 100% | Simulation 
Please UpvoteCode
# Please Upvote

# Code
```python3 []
__import__("atexit").register(lambda: open("display_runtime.txt", "w").write("0"))
class Solution:
    def lastVisitedIntegers(self, nums: List[int]) -> List[int]:
        seen = deque([])
        ans = []
        k = 0
        for num in nums:
            if num==-1:
                k+=1
                if k<=len(seen):
                    ans.append(seen[k-1])
                else:
                    ans.append(-1)
            else:
                k=0
                seen.appendleft(num)
        return ans
```
['Python3']