#3257

Maximum Value Sum by Placing Three Rooks II

hard · 26.9% accepted · 60 likes · top 5%

array · dynamic programming · matrix · enumeration

⊣ practice⊣ open on leetcode ↗

Description

You are given a m x n 2D array board representing a chessboard, where board[i][j] represents the value of the cell (i, j).

Rooks in the same row or column attack each other. You need to place three rooks on the chessboard such that the rooks do not attack each other.

Return the maximum sum of the cell values on which the rooks are placed.

Solution