What I did in my code (please check, my logic is correct or not) -
we have array of n numbers :
let, array is :arr[] = [1 2 3 4 5] // (size = 5)
I declared a new array"mul" with size (n + 1) and take mul[0] = 1
then iterate through arr and update mul[i] with (mul[i - 1] * arr[i]) % M, which gives mul as -
mul = [1, 1, 2, 6, 24, 120] // here, M = 1e9
Here, mul[i] gives multiplication of array till ‘i’ mod M
Is this approach is correct? If correct then where it gives runtime error.
Just analysis and guesswork in this particular case: I couldn’t see any out-of-bounds accesses or other sources of Undefined Behaviour, so that kind of left division by 0 as the most likely possibility. It was then a simple matter to contrive an example that triggers one
Unable to think about this question. Pls help.
I read its editorial but stucked at cumulative frequency. What is cumulative freq and how it was calculated.
Please give some idea to solve this problem.