Search
⌘K
Get Premium
Leetcode 2899. Last Visited Integers
Scan nums keeping a stack (most-recent-first) of positive integers and a counter of consecutive -1s. When you see a positive, push it and reset the counter; when you see -1, increment the counter k and output the k-th most recent seen value (or -1 if it doesn't exist).
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.