Opening your workspace…
Workspace/Coding room
Opening your workspace…
The kitchen has installed a ticket rail with a little red bell at one end. Ring it and the newest ticket still on the rail drops into the soup. Read events in order. A positive number adds a ticket bearing that number to the end of the rail. A zero rings the bell and removes the last remaining ticket, if there is one. Equal numbers are separate slips, and anything that lands in the soup stays there. Return the numbers still on the rail, oldest first.
[8,3,0,5]Output[8,5]The zero removes ticket 3, so the board ends with 8 followed by 5.
[0,4,0,0]Output[]The first zero finds an empty board, the second removes ticket 4, and the third again has nothing to remove.
An undo always removes the newest ticket still on the board. Which end of an array can act as the top of a stack?
/** @param {number[]} events * @returns {number[]} */ function solve(events) { // Return the tickets left on the board, oldest first. }
Tab inserts two spaces. Shift+Tab outdents. Use the arrow keys and Tab to choose a suggestion. Press Escape, then Tab, to leave the editor. Press Control or Command with apostrophe to run samples or with Enter to submit.
[8,3,0,5][8,5]