Given an integer 2D matrix (of size n x n), find the smallest sum possible while moving from the element at (0,0) to the diagonally opposite end i.e. till the element at n x n.
Input matrix will be a square matrix of size n x n. While moving to the diagonally opposite end, the following rules are to be followed :
1. From a given element you can move to the element directly below it 2. From a given element you can move to the element to right of it
Keeping the following rules in mind, you have to return the smallest sum that is possible while moving to the diagonally opposite element.
Input format :
Line 1 : n
n lines containing matrix elements separated by space
Sample Input :
4 1 10 10 10 1 10 10 10 1 10 10 10 1 1 1 1
Sample Output :
Login to submit your solution