Sponsored
Sponsored
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.
Solve with full IDE support and test cases
How can two-pointers be used to solve this problem optimally?