LONGEST CONSECUTIVE SEQUENCE (Leetcode) [Python] - Code & Whiteboard

preview_player
Показать описание
A linear, super easy-to-understand solution to Leetcode's Hard problem #128 - Longest Consecutive Subsequence.

Let me know what you want to see next, or if you have any questions about this one! :)

---------------------------------------------------------------------------------------------------------------------------------------------------------------
Let's connect on LinkedIn!

Follow me on Medium!

Questions or suggestions for new videos? Email me!
Рекомендации по теме
Комментарии
Автор

thanks man for this type of solution, rest on different sites have very hard to understand code solution i almost gave up when i found yours.

DivitMukhi
Автор

man, your explanations are always so elegant. thank you, keep up the great work.

dhruvmohapatra
Автор

Vo bro, you were so easy to understand, I have my interview tomorrow, thnx alot!!.

Aryansingh-fkhy
Автор

Very elegant solution ! I was struggling to understand why implement it in hashtables and found you video

mohammedfahadnyc
Автор

I comprehended 101% of what you said.Keep up the good work.

tombrady
Автор

if u use a priority queue and a hashset its alot easier to digest imo, thats how i solved it. But this is also a great solution :)

allaboutthementality
Автор

Thanks once again, this may be the easiest hard problem..

JohnDoe
Автор

I am a bit lost. Suppose nums = [1, 2, 3, 4, 5, 100]. Now num will take 1 and then go all the way to 5 to get count = 5. Next num will be 2 and then again go all the way up to 5 to get 4. Then we take 3 which will also go all the way upto 5. So is this not O(n^2)

utkarshkumar
Автор

hi thanks for the great explanation.
why the complexity is O(n) where we have while inside the for?

Rolahd
Автор

But if there are two nested loops then how is this a O(N) complexity

mayurkalsekar
Автор

Thanks for the solution, is it O(n) solution.?

krishnanduranjnroy