Question: A Hackerrank Challenge: Given an NxN matrix, slice it and find the minimum slice weight. A slice consists of all the elements that are below,

A Hackerrank Challenge:

Given an NxN matrix, slice it and find the minimum slice weight.

A slice consists of all the elements that are below, below right, or below left 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; 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.

KEEP IN MIND THAT THE MATRIX IS NOT 3 X 3, BUT N X N.

The minimum slice would be 1 4 7 in this case because 1+4+7 is the minimum of all the sums;

Write a function public int FindMinSlice (List> Matrix) that returns the min slice weight.

NOTE: Psuedocode is accepted. I want to know the approach of solving this question.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!