Sir, i solve this question. But, i have doubt in time complexity

sir, here ‘n’ is given of order 10^6. aur mai jish method se question solve kiya hai. mujhe lgta hai ki, iski worst case me time complexity ‘n^2’ ho jayegi. kya mera solution efficient hai ya aur koi efficient solution ho skta hai ? My code -> https://ide.codingblocks.com/s/467131

hello @chandreshmaurya

ha worst case mein to O(N^2) hi jayega time compelxity.

tumhara solution to sahi ,isse efficient logic to nahi aa raha mere dimag me abhi

ohkay sir, thank you

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.