Available question text
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).
Related questions
Continue with questions that share topics or the same question type.
- Last Visited Cell in a Directional Grid
Coding
- Add Two Integers
Coding · Math
- Append K Integers With Minimal Sum
Coding
- Array Prototype Last
Coding
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 2899. Last Visited Integers
Interview date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source