Implement prototype(tokens: list[str]) -> bool and solve with the same signature. Each token must be exactly LOAD:<nonempty-label> or UNLOAD:<nonempty-label>, with no additional colon. Malformed tokens raise ValueError when reached. Return whether the complete sequence is valid LIFO order; [] returns True.
Process left to right. Return False at the first ordering violation without inspecting later tokens: ['UNLOAD:x', 'bad'] returns False. A reached 'LOAD:' raises ValueError.
Prototype: use adjacent-pair reduction while preserving the processing rule. Final: use a stack. Preserve the token list, including on failure.
Drag or use the arrow keys to resize. Home collapses the question; End collapses the editor. Enter or double-click resets the split.
Loading editor…
Loading editor…
No results yet.
Complete the starter code, then run the checks.
Results and errors will appear here.