given an nxn matrix, slice it and find the minimum slice weight.
Answers
solution:
Given an NxN matrix, slice it and find the minimum slice weight.
A slice consists of all the elements that are right below and left below of the element above it. The Min Slice Weight is the minimum sum of all elements in the slice.
Example: given input
1 2 3
4 5 6
7 8 9
The slices would be 1 4 7; 1 4 8; 1 5 7; 1 5 8; 1 5 9; 2 4 7; 2 4 8; 2 5 8; 2 5 9;2 6 8; 2 6 9 ....etc.
The minimum slice would be 1 4 7 because 1+4+7 is the minimum of all the sums;
Write a function public int Find Min Slice (List<List<Integer>> Matrix) that returns the min slice weight.
For an n * m matrix, the sum of the matrix is the element in the first row to the last row.
The condition is that you can move diagonally from left or right or vertically downward in it.
Since you are slicing the matrix hence the number of the child matrix will be half of the original.