Hudson River Trading | OA | Two rooks
Anonymous User
11929

Hi all,

Took HRT OA today. This is one of the questions.

You are given a chess board (2D array) where each square is assigned a non negative integer. Two rooks are to be placed on the chess board such that they don't kill each other and sum of the values of the squares they are placed in should be maximim. Return the maximum sum.

Example:

Input:
0 1 5
3 0 5
1 4 1

Output:
9

I just solved by sorting the given 2D array. I coudn't think of more optimized solution.

Comments (6)