Back to questions

Maximum Sum of a Matrix Stripe Python Interview Question

Maximum Sum of a Matrix

Stripe Python Interview Question

We define the Matrix Sum of a matrix as the maximum possible sum of matrix elements such that none of the selected elements share the same row or column.

Given a matrix of integer numbers, return the Matrix Sum.

Example #1

3-12
456
-789

Input: matrix =

Output: 17

Explanation: One possible way of selecting is 3, 6, and 8. You can also select 3, 5, and 9, but the result will still be 17.

Input

Python

Output