4 ms·
The stack solution checks that the stack is non-empty before popping. The counter solution simply needs to check that the counter is non-zero before decrementi
by braythwayt 8y ago
The stack solution checks that the stack is non-empty before popping.
The counter solution simply needs to check that the counter is non-zero before decrementing.
All cases then work perfectly.