Code
The highlighted line runs next. The pill shows the live values in the running call.
Cost
Work done so far, and how the three solutions compare
Calls and output
Each call, with what it returns underneath
The highlighted line runs next. The pill shows the live values in the running call.
Work done so far, and how the three solutions compare
Each call, with what it returns underneath
Keyboard: ← → step, Space play or pause. Type calls like "set key value time, get key time" (up to 14; keys and values 1–8 lowercase letters or digits; times 0–999, with set times strictly increasing), or paste LeetCode's list. The brute-force code uses −1 as "nothing found" so a timestamp of 0 still works. In Java and C++ the hash map's iteration order isn't defined; the trace shows insertion order.