Python program - Matrix triangle sum

Hi all,

Need help in understanding the approach of this program.

iam kind of weak in matrix kind of problems.


Thanks in advance.

Hey, if we observe properly, the sum of rowNo. and coloumnNo. in the above triangle will be <=N, so while traversing the matrix, we can check for the condition if(i+j < N), then we add the value to upperTraingleSum, else we add the value to the lowerTraingleSum. This should according to the given conditions.
Thanks!

1 Like