3189. Minimum Moves to Get a Peaceful Board
Given a 2D array
rooks
of lengthn
, whererooks[i] = [xi, yi]
indicates the position of a rook on ann x n
chess board. Your task is to move the rooks 1 cell at a time vertically or horizontally (to an adjacent cell) such that the board becomes peaceful.A board is peaceful if there is exactly one rook in each row and each column.
Return the minimum number of moves required to get a peaceful board.
Note that at no point can there be two rooks in the same cell.
1 | class Solution { |