Remove Element - Leetcode 27 - 2 Pointers (Python)

preview_player
Показать описание


Please check my playlists for free DSA problem solutions:

My Favorite Courses:

Data Structures & Algorithms:

Python:

Web Dev / Full Stack:

Cloud Development:

Game Development:

SQL & Data Science:

Machine Learning & AI:
Рекомендации по теме
Комментарии
Автор

I am circling back to solve this really in the most optimised way and all the approaches I saw or explored, I was not able to visualise it well, but this one literally got to my head in first go. Thank you so much.

arrowxvibe
Автор

For me the most complicated part is how to come to this solution. I mean algorithm. For me its not obvious. This is the most hard part.

vadymchecherinda
Автор

Dude!! Your explanation is awesome please continue to do the same 😄

johnhyde
Автор

Thank you for the playlist bro it's really helpful 🙌

MoTosifAnsari-ye
Автор

theres a much easier way, u can just iterate the array backwards and remove occurences of nums[i]==val by just del nums[i], hence shifting wont be affected since its backwards,
space complexity is o(1) with 17.78mb of memory usage, idk bout time comp

vaishnavsnair
Автор

Hardest part is to understand what to return. Does it want a int? a list? By seeing the Output in the descrpition it looks like it want both, but the function asks for a int.

thiagoribs
Автор

while val in nums:
nums.remove(val)
k=len(nums)
return k
What about this Solution??
👆☝

memelover
Автор

why isnt n initialized to len(nums)-1?

Insigna
join shbcf.ru