Problem in Best Approach

please explain with an example .

hello @Riya.ty6 this type question is important and you can see them in your interviews .
@Riya.ty6 prateek sir also has made one video on this question .
have you seen that video ?
if not here i am attaching the link for the video .


please do watch this video of prateek sir and then also if you have problem then please ask here .
i will clear all your queries .
Happy Learning !!

hey , thank you for the link. but i checked out that video and that did not have The best Approach given in tutorial the one without using extra space

hey @Riya.ty6 the best complexity in which you can do this code is 0(n) only .
it is the optimised approach only .
and in case of space complexity also you need two extra arrays to apply your logic .
try to submit this approach you will be able to submit for the test cases according to constraint .


if you feel that your doubt is cleared please mark this doubt as resolved .
Happy Learning !!

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.