beginner's approach
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```\n/**\n * @param {number[]} nums\n * @return {number[]}\n */\nvar lastVisitedIntegers = function (nums) {\n  const len = nums.length;\n  let seen = [];\n  let ans = [];\n  let k = 0;\n  for (let i = 0; i < len; i++) {\n    if (nums[i] > 0) {\n      seen.unshift(nums[i]);\n      k = 0;\n    } else {\n      if (k >= seen.length) {\n        ans.push(-1);\n      } else {\n        ans.push(seen[k]);\n        k++;\n      }\n    }\n  }\n  return ans;\n};\n\n```
['JavaScript']