This problem is a bit tricky.
The key point is that A passes B in two ways:
- Directly passing by.
- Putting into the stack.
So, in simple terms, just simulate and see how it goes.
When you find it impossible, then it's a NO.
This problem is a bit tricky.
The key point is that A passes B in two ways:
So, in simple terms, just simulate and see how it goes.
When you find it impossible, then it's a NO.