can you please elaborate me this problem’s core
Divisible subarray
can you mention the time stamps where the code wasn’t understood by you? so that i can elaborate that line to you.
See the main idea behind this problem is:
In the above sequence, there are N terms.There are two possible cases:
- If one of the above prefix sums is a multiple of N then print the ith subarray indices.
- If None of the above sequence elements lies in the 0 modulo class of N , then there are (N – 1) modulo classes left. By the pigeon-hole principle , there are N pigeons (elements of the prefix sum sequence) and (N – 1) holes (modulo classes), we can say that at least two elements would lie in the same modulo class. The difference between these two elements would give a sub-array whose sum will be a multiple of N .
1 Like
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.