my code for divisible subarrays problem is working fine for statically created pre[] but gives wrong output in case of dynamically created pre[].
Getting incorrect answer if i create the bucket array dynamically! please help
hi @Usha24
it is printing garbage values
as you have not initalize the arrray with 0
use this
long *pre = new long[n]{};
after that garbage value will not print
i hope this help
if you have more doubts regarding this feel free to ask
if your doubt is resolved mark it as resolved from your doubt section inside your course
I have initialised it with 0
I have used memset to initialise the dynamic array with 0.
Can you check again once
don’t use memset instead use a loop to initialise
or use
long *pre = new long[n]{};