Wrong output in the program for sum of of all submatrices using prefix sum method


this is the link for my code

Hello @mansi_sharma9kF,

The junk values are getting added and subtracted from the sum for the cases:

  1. When li=0
  2. when lj=0

You have to check for these cases before computing the sum.
Modified Code:

Hope, this would help.
Give a like if you are satisfied.

1 Like