Opening your workspace…
Workspace/Coding room
Opening your workspace…
A lookout on Wall Rose has spotted a Titan. The captain orders every occupied tower to ring back once its crew has heard the warning. Somewhere to your left a bell rings twice. The captain keeps her hand on the gate lever. Two bells from one tower still means one crew has heard.
You have the list of occupied tower IDs and a log of signals in time order. Each signal gives a minute and a tower ID. Return the first minute by which every occupied tower has signaled at least once. Ignore signals from towers outside the list. If anyone is still silent when the log ends, return -1. If no towers are occupied, return 0.
[2,4], [[1,2],[2,2],[5,4]]Output5Tower 4 first rings at minute 5.
[3], [[2,9]]Output-1Tower 3 never rings.
Remove each tower from the waiting set the first time it signals.
function solve(occupied, signals) { // Write your solution here. }
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.