Skip to main content
added 86 characters in body
Source Link
Quintec
  • 2.9k
  • 10
  • 7

Non-overlapping Matrix Sum

Given k m by n matricesk arrays of length n, output the maximum sum possible using one element from each matrix such that no two elements are from the same position. It is guaranteed that k<=mnk<=n.

Input

ExA nonempty list of nonempty arrays of integers.

Output

An integer that represents the maximum sum.

Examples

1Input 2-> Output
[[1]] 1-> 21
[[1, 3], [1, 3]] -> 4
3[[1, 4, 32], 4[5, 6, 1]] ->7(3+4> 9
[[-2, can’t-21],[18, choose2]] the-> 0
[[1, 2, fours3], in[4, the5, same6], place)[7, 8, 9]] -> 15
[[1, 2, 3, 4], [5, 4, 3, 2], [6, 2, 7, 1]] -> 16

Is the challenge clear? More test cases and formatting to be added when I’m not on phone

Non-overlapping Matrix Sum

Given k m by n matrices, output the maximum sum possible using one element from each matrix such that no two elements are from the same position. It is guaranteed that k<=mn.

Ex.

1 2  1 2

3 4, 3 4 ->7(3+4, can’t choose the 2 fours in the same place)

Is the challenge clear? More test cases and formatting to be added when I’m not on phone

Non-overlapping Matrix Sum

Given k arrays of length n, output the maximum sum possible using one element from each matrix such that no two elements are from the same position. It is guaranteed that k<=n.

Input

A nonempty list of nonempty arrays of integers.

Output

An integer that represents the maximum sum.

Examples

Input -> Output
[[1]] -> 1
[[1, 3], [1, 3]] -> 4
[[1, 4, 2], [5, 6, 1]] -> 9
[[-2, -21],[18, 2]] -> 0
[[1, 2, 3], [4, 5, 6], [7, 8, 9]] -> 15
[[1, 2, 3, 4], [5, 4, 3, 2], [6, 2, 7, 1]] -> 16
Source Link
Quintec
  • 2.9k
  • 10
  • 7

Non-overlapping Matrix Sum

Given k m by n matrices, output the maximum sum possible using one element from each matrix such that no two elements are from the same position. It is guaranteed that k<=mn.

Ex.

1 2  1 2

3 4, 3 4 ->7(3+4, can’t choose the 2 fours in the same place)

Is the challenge clear? More test cases and formatting to be added when I’m not on phone