AO
Back

Token Expiry and Reset Simulation (LC 1797-style)

OAAsync OALast reported June 2026Low Frequency

Problem Overview

Authentication tokens. After a user logs in they receive a token. The token expires once the system's time limit, expiryLimit, has passed; resetting it while it is still valid (up to and including its expiry time, as the example shows) extends it. A valid token can be reset any number of times. A reset of a token that has expired or does not exist is ignored, and an expired token cannot be used again.

Each command is [type, token_id, T]:

  • type 0 (create): create token token_id; it expires at T + expiryLimit.
  • type 1 (reset): extend token token_id so it expires at T + expiryLimit.

There are no tokens at the start. Process the commands in order, then return how many tokens are still valid at the latest time T.

Example (as posted)

expiryLimit = 4
commands = [[0, 1, 1], [0, 2, 2], [1, 1, 5], [1, 2, 7]]

[0, 1, 1]  create token 1 at T = 1; it expires at 1 + 4 = 5
[0, 2, 2]  create token 2 at T = 2; it expires at 2 + 4 = 6
[1, 1, 5]  reset token 1 at T = 5; still valid (T <= 5), so it now expires at 5 + 4 = 9
[1, 2, 7]  reset token 2 at T = 7; it expired at T = 6, so the reset is ignored

At T = 7 only token 1 is still valid. Return 1.

Notes from the reports

  • Reported three times in Citadel online assessments, from February 2025 to mid-2026. One report posts the prompt and example above; the others call it a lazy delete and "a bit simpler than LeetCode 1797".
  • Not stated in any report, so confirm or state your assumption:
    • Can a create reuse an id that already exists?
    • Is a token that expires exactly at the latest time still counted?
    • Are the commands always in non-decreasing time order?
  • No input sizes or function signature were reported.

What Reports Emphasize

What passers do: Lazy deletion: the candidate who described it that way solved all three problems of the assessment in half an hour

Practice

Write your own against 8 test cases, or read the worked solution — approach, complexity, and code that runs.

Prepping for Citadel with friends?

Send them this page. It is free to read, no account needed.

More Citadel Questions

Free preview

Every question in the Citadel catalog gets this depth

What you just read — canonical solution, follow-up arc, what passing candidates actually did — exists for all 62 Citadel questions, refreshed monthly from new candidate reports.

$59/mo — or $50/mo with the 3-month pass · cancel anytime
Citadel · OA · Reported 3× across candidate reports
Is this helpful?