Code
Loading editor...
Tap Analyze to see visualization
Click Analyze to visualize
See step-by-step execution, variables, and output
Variables
Run code to see variables
Output
Console output will appear here
Click Analyze to visualize
See step-by-step execution, variables, and output
Run code to see variables
Console output will appear here
Maintain a stack of unresolved indices with decreasing temperatures. When a warmer day arrives, repeatedly pop colder indices and fill their wait times. Push current index afterward.
Each index enters and leaves the stack at most once. The stack invariant guarantees the first warmer day for a popped index is the current index.
Updated Feb 2026