3189. Minimum Moves to Get a Peaceful Board
ArrayGreedySortingCounting Sort
Hints
Hint 1
Think of a greedy method.
Hint 2
First, distribute the rooks in individual rows.
Hint 3
You can do this by sorting all rooks by their rows. Then assign the first one to the first row, the second one to the second row, and so on.
Hint 4
After you've distributed rooks across all rows, now do the same for columns.
Hint 5
Sort rooks by their columns and then assign the first one to the first column and so on.
Preparing judge…