Divisible sub array

The approach discussed in above questions fails for the case:
n = 6

1 , 3 , 2 , 6 , 4 , 4

According to the approach number of good subarray is:
2

But there are 4 : [1,3,2] [1,3,2,6] [6] [2,6,4]

@vkth lets see
0 1 2 3 4 5 i
1 3 2 6 4 4 arr
1 4 6 12 16 20 cumsum
1 4 0 0 4 2 cumsum % 6
2 subarray have value 4,
2 subarrays have value 0
so total subarrays = 4

Yes, I understood that we have to separately add count for zero sum sub array.

@vkth do you need any further help?

No, I got it now.
Thank you :slight_smile:

@vkth please mark your doubt as resolved :slight_smile:

I did that yesterday. I am having the option to re-open doubt now.

1 Like