please explain the query function here, what does it do and how…??
Simple Enough code
Though the approach which you are doing goes like this:
n this approach, we take into consideration that N/2 will eventually reduce to 0 or 1. Therefore for every N we are finally reducing our calculations to N%2, and hence this leads us to the conditional return statements.
Since the function execution is symmetrical in the order N/2, N%2, N/2
N%2 is always in the mid of the sequence for every N.
In the very beginning we have calculated the total length of sequence to determine initial length of the sequence.
Thank you @Tushar, you explained the logic well, and yess I wasn’t able to crack the code logic after so much striving, so just looked up for the solution.
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.