Find where to place the Nth rook using a rook-counting function.
Unlock detailed company stats for this questionUpgrade
On an NxN board, N-1 rooks already stand so that no two attack each other (no row and no column contains more than one rook). Place the Nth rook and return its position (i, j), but you do not know where the current rooks are. You have countRooksInsideRectangle(a, b, c, d), which returns the number of rooks within the rectangle formed by horizontals a, b (a <= b) and verticals c, d (c <= d). Example: n=3, countRooksInsideRectangle(2,3,1,3) -> 2, countRooksInsideRectangle(1,1,1,1) -> 0, answer: (1,1) (the board is 1-indexed).
Community answers
No answers contributed by the community yet.
Related courses

Course

Course
Course
