i holds stock[i] items. Trips windows arrive one after another, where windows[j] = [l, r]: the trip passes shelves l through r inclusive and may take one item from any of them, whether that is one shelf, several, all of them or none.
Return True if all shelves can be left empty after every trip, and False otherwise.stock=[1, 2, 0, 1], windows=[[0, 1], [1, 3]] → True
The first trip takes one item from shelves 0 and 1, the second one from shelves 1 and 3, skipping the empty shelf 2. Every shelf ends up empty.
stock=[2, 1], windows=[[0, 1]] → False
Shelf 0 holds two items, but there is only one trip, so just one of them can be taken.
stock=[1, 2, 0, 1], windows=[[0, 1], [1, 3]]
True
Run checks the first 3 tests in your browser. Submit checks all 101 tests on the server, hidden ones included.