Why is the query part giving wrong answer, can someone point out the mistake?

hello @shibangi

please check in the question whether the indexing of queries given is 1 based or 0 based. if it is 1 based then u need to subract from from l and r and then make call on query function.

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.