Counting in Byteland

my code worked…i have a doubt though
i am using 3d fenwick tree
for update when i was keeping my loop as i=a; i<(N+1); i+=(i&(-i)) it wasnt working…when i changed the N+1 to 105 (size of my fenwick tree) it worked…isnt it enough to check till N+1 always?? as fenwick tree goes from 1 to N??

@shameek.agarwal
Might be some implementation issue
As you may see even here https://www.hackerearth.com/practice/data-structures/advanced-data-structures/fenwick-binary-indexed-trees/practice-problems/algorithm/counting-in-byteland/editorial/
If you update till just N it is fine which you did as well
You can compare your approach with this once and see what the issue might be

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.