An electronic market routing optimization challenge at Hudson River Trading (HRT) models order routing allocations across an grid of latency-yield scores grid.
You must place two non-attacking rooks on two distinct cells and of the grid such that they do not share the same row or column:
Your Task
Implement two_rooks_max_sum(grid: list[list[int]]) -> int that returns the maximum possible sum of yields in time.
Constraints
Examples
grid = [
[1, 4, 3],
[2, 5, 6],
[3, 8, 2]
]
# Best pair: (2, 1) with value 8, and (1, 2) with value 6.
# Rows 2 != 1 and Columns 1 != 2.
# Sum = 8 + 6 = 14
# Output: 14