Remove All Adjacent Duplicates in String II - Leetcode 1209 - Python

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


0:00 - Read the problem
2:00 - Drawing Explanation
9:58 - Coding Explanation

leetcode 1209
#amazon #interview #python
Disclosure: Some of the links above may be affiliate links, from which I may earn a small commission.
Рекомендации по теме
Комментарии
Автор

Just got the news today that I'll be getting an offer from Amazon.
Thank you so much for all the effort you continue to put in this channel!
It really changes lives!

しげお-il
Автор

Your vids are great, it's helped me progress to the point I can solve most mediums! I just solved this one before you uploaded (it is the daily challenge).

ostenloo
Автор

I love you neet code 🤗 these videos are always a fantastic reference for when I am confused af. And huge respect for doing so much work for me by creating that website for me to track my blind 75 progress and you didn't even throw ads on it! I've got my first faang interview in just under two weeks and if I get it I attribute it 100% to your fantastic creations! Keep up the great work! I'm sure you will make it super far if you keep working as hard as you do!

the_real_briel
Автор

Wow, every time I watch Neetcode, I feel my brain refreshed! Thank you so much!

mariagu
Автор

Oh my gosh, this is incredibly intuitive. Push out what you can I love seeing these man!

Nerdimo
Автор

Hi NeetCode,
Thank you for this great video. But speaking of final part of you solution.
In python string is immutable. So every time you use res += (char * count). It will not simply add char behind original string.
In fact it will create a new string object to achieve this += statement.
My question will be would it be more efficient to use a list to store all char by appending them and return "".join(res)?

ChenAubrey
Автор

The idea of combing value and count together is brilliant.🎉

alexl
Автор

Nice explanation, I solved this on my own with a stack but you did it much cleaner and in a better way, thank you

symbol
Автор

Automatic like even before watching the entire video. Insane right ? Nah ... just complete confidence in the quality of your content. Hope you are feeling better now !!!

vdyb
Автор

always content as always neetcode! just a question though. wont you get in trouble if you make coding interview vids? i recall techlead got into trouble cuz of his youtube content with google

Justicex
Автор

Appending to a string in python is an O(n+m) operation. The last loop looks O(n**2) to me.

bmwdude
Автор

I feel a little accomplished if I were to solve the problem after the coding explanation without looking at your solution. Now all I need is to find the solution without looking at the explanation.

TheQuancy
Автор

I thought of using stack, slowing building it one at a time keeping a top pointer and a start pointer(Star pointer and top are different only if there exists a continuous sequence of same chars) and use those pointers to remove continuous chars of Len k

infinitygod
Автор

I am not sure if this would be a valid test dataset: abcbbccaa.

If i am correct your explanation says that it would return "" in accordance of the stack a:3 b:3 c:3 though you can clearly see this string would return itself as leftovers.

How would we take this datapoint in account?

Odinh
Автор

I think that part when you creating res can be simplified to:

return ''.join([char * count for char, count in stack])

ksawerylejczak
Автор

Could you pls explain on how to do it if instead of adjacent same character, we have to remove if a pattern is repeated
Eg. Input - abcabcabcd
Output - abcd
Thanks

chetansn
Автор

Your videos are awsome...Great Work...

__agpatel__
Автор

As soon as I saw the question, I knew it was similar to parenthesis problem. I wonder why this is medium difficulty, since it's very very similar to prenthesis problem.

omkarbhale
Автор

I wish you learn Javascript and do the coding on Javascript :(
Would make a lot of people happy.

__--__--__--__--
Автор

But what about a string like ababa and k = 2? If we follow this method, then you will just end up deleting the entire string

samyuktaneeraj