Easy Ruby Solution 100% Comments
Complexity\n- Time complexity: O(N)\n\n# Code\n\n# @param {Integer[]} nums\n# @return {Integer[]}\ndef last_visited_integers(nums)\n    ans = []\n    seen = []\
# Complexity\n- Time complexity: O(N)\n\n# Code\n```\n# @param {Integer[]} nums\n# @return {Integer[]}\ndef last_visited_integers(nums)\n    ans = []\n    seen = []\n    k = 0\n    \n    nums.each do |num|\n        if num > 0\n            seen.unshift(num)  # Prepend the positive integer to seen\n            k = 0              # Reset k since this breaks the consecutive -1 sequence\n        elsif num == -1\n            k += 1             # Increase k for each consecutive -1\n            if k <= seen.size\n                ans << seen[k - 1]  # Append the k-th last seen integer\n            else\n                ans << -1           # Not enough elements in seen, append -1\n            end\n        end\n    end\n    \n    ans\nend\n\n```
['Ruby']