Why is this code not working for this problem?

Why is this code not working for this problem?

hello @cbcao263
check now->

Thanks Sir,
It’s working now

And Why Can’t I use arr.pop() instead of arr.resize()?
Because it will be doing same thing only.

Also If I checked on Leetcode, The Time Complexity was a lot.
Was it due to insert operation as I am inserting in middle so it will gonna take a lot of time
Or any other reason?/

yeah insert is almost O(n) , so ur solution time complexity is is O(n^2)

refer this for all valid approaches->link

Thanks Sir
for this one
O(n2) is a very large.
Thanks :slight_smile:

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.