Rust Straightforward Solution
Code\nrust []\nuse std::collections::VecDeque;\n\nimpl Solution {\n  pub fn last_visited_integers(nums: Vec<i32>) -> Vec<i32> {\n    let (mut seen, mut ans, mut
# Code\n```rust []\nuse std::collections::VecDeque;\n\nimpl Solution {\n  pub fn last_visited_integers(nums: Vec<i32>) -> Vec<i32> {\n    let (mut seen, mut ans, mut k) = (\n      VecDeque::new(), VecDeque::new(), 0,\n    );\n\n    for n in nums {\n      if n > 0 {\n        seen.push_front(n);\n        k = 0;\n      } else if n == -1 {\n        k += 1;\n        ans.push_back(\n          if k <= seen.len() {\n            *seen.iter().nth(k - 1).unwrap()\n          } else { -1 }\n        )\n      } else { k = 0 }\n    }\n\n    ans.into_iter().collect()\n  }\n}\n```
['Rust']