Here’s my solution : Link

Any test case where this is failing?

Declare all integers as long long , this is the only mistake you are doing .

Edit:-

**just declare your ‘tree’ array as long long , because you are returning the array element to long long find_sum**

1 Like

But they’ve mentioned that the maximum number of marbles each student has, never exceeds the size of int, right?

Isn’t it enough to take just their sum as long long?

But the sum may exceed right ???

1 Like

just declare your ‘tree’ array as long long , because you are returning the array element to long long find_sum , i have edited the answer

Ohh… all right…

Thanks

welcome