Sponsored
Use these hints if you're stuck. Try solving on your own first.
Sort the matrix row indexes by the number of soldiers and then row indexes.
Solve with full IDE support and test cases