Lets say you have a matrix. Write a function which takes cell points and a number k. (It returns sum from rows).
for ex: func(i, j, k) here i and j are cell position. And k is a number. // I want sum from continuous rows.
I want sum from mat[i][j-k] to mat[i][j+k] + sum from mat[i-1][j-(k-1)] to mat[i-1][j+(k-1)] + sum from mat[i-2][j-(k-2)] to mat[i-2][j+(k-2)] and so on. If you go out of border add zero (do nothing).
Help me please Tell me if i clearly explai the problem or not.
It is important to mention that k is constant every time we call the function but not the i and j. So we need to do the pre computation. Help sir, tfg
Why on earth did you ping me specifically?
You want to take the sum of this triangle: https://i.328888.xyz/2023/04/14/ixDSDx.png
We could actually just take the left half of the triangle, and then for the right half, we could just flip the whole array left and right and apply the same algorithm.
https://i.328888.xyz/2023/04/14/ixU0VN.png
So you just have to figure out the sum of all the x's and y's, the orange part, and then you can figure out the sum of the triangles.
What is the orange part? How to figure out x's and y's. And how is it actually giving us the sum of one part of triangle. Hard to understand 😖