Using deque || C++
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```\nclass Solution {\npublic:\n    vector<int> lastVisitedIntegers(vector<int>& nums) {\n        deque<int>seen;\n        vector<int>append;\n        int k=0;\n        for(auto it:nums){\n            if(it!=-1){\n                seen.push_front(it);\n                \n                k=0;\n            }\n            else{\n                k++;\n                if(k<=seen.size()){\n                append.push_back((seen[k-1]));\n                \n                }\n                else{\n                    append.push_back(-1);\n                }\n\n            }\n        }\n        return append;\n    }\n};\n```
['C++']