Query bits question

Code is not getting submitted, please tell the error.

Hi,

Your update function will not give correct updates because there is no case of complete overlap in case of update. you have to go to the leaf and update recursively. however, you can perform lazy updates in complete overlap. Also you are assigning -1 to tree idx while backtracking the tree whereas you should assign each tree node a specific number.

Think again and try to solve this problem by yourself.
If you still get issue go to the link:

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.

Okay sir, I’ll try to solve it again. Thank you.

Sir, I tried another approach using lazy segment tree, but it is giving wrong answer.

Hey! when making updates take in account that position of bits matter, while updating. think how the number will change for the given update. In parent nodes store the number formed by child.

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.