For a point p(i,j)
, it’s position in a matrix is equal to i*width+j
where width
is the width of the matrix. Hence the number of cells between two elemets is abs((i1*width+j1) - (i2*width+j2))
.
1
solved How do i know number of cells between two points in array?