while taking mod for negative number in the code why dont we take if condition…rather we have directly tsken sum%=n and then sum=(sum+n)%n…i think before (sum+n)%n we should take if condition…like if sum is negative then…
Disvisible subarray code
Hello @Vibhuti0206,
Yes, you can use if condition.
But, if you see carefully then you would observe that doing (sum+n)%n would not affect the positive value.
So, it’s completely your choice.
Hope, this would help.