Get Maximum Sum
Problem Overview
- Select exactly x elements from an n x n matrix to maximize the sum, with at most factor[i] taken from row i; return -1 if impossible.
- Inputs: factor[n], data[n][n], x. Output: maximum sum (long integer) or -1.
- Constraints: n <= 1000, data[i][j] <= 1e9, 1 <= factor[i] <= n.
- Real-world context: Amazon prototype for matrix compression; an Amazon interviews coding interview problem and interview question.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
