Sponsored
Sponsored
Solve with full IDE support and test cases
Use these hints if you're stuck. Try solving on your own first.
For each fort under your command, check if you can move the army from here.
If yes, find the closest empty positions satisfying all criteria.
How can two-pointers be used to solve this problem optimally?