Why is my solution is wrong?
and I couldn’t understand the answer.
I have found another solution.
You have already found out, the issue is with your code
In the solution code,
4. So the first for loop will iterate through each row and the second for loop will traverse through each column of the current row.
matrix[row][col] will fetch us each and every item in the matrix.
4 and so on.
total += matrix[row][col] will get us the sum of all the values.
Hope it’s clear now.