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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started