how are we able to deduce the above relation between variables
Cant understand why (b-a)%N=0
hello @king-slayer97
we are looking for subarray which is divisible by n right?
[…a…b…] (let say this array is cummulative sum array, i.e a is indicating sum of all elements in its left incluing itself,
similarly b is indicating sum of all elements in its left incluing itself)
now how we can get sum of elemets that occur in between index of a and index b.
[…a…]
[…b…]
we can simply subtract a from b (ie b-a).
and becuase we want to check whether it is divisible by n or not
we are using (b-a)%n
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.