Longest Consecutive Sequence | LeetCode 128 | C++, Java, Python

  Рет қаралды 4,572

Knowledge Center

Knowledge Center

Күн бұрын

Пікірлер: 16
@SonuSharma-fc9hd
@SonuSharma-fc9hd 3 жыл бұрын
Your teaching style is awesome. I like our voice 😅
@KnowledgeCenter
@KnowledgeCenter 3 жыл бұрын
Thanks for the motivating words.
@prasantharavindramesh1078
@prasantharavindramesh1078 3 жыл бұрын
awesome explanation.Just a small clarification.The consecutive sequence can be in any order is true but what if the consecutive sequence has duplicates like for the above example say [100,1,200,1,10,4,0,3,8,2].Here the consecutive sequence is [0,1,1,2,3,4] so i need to store the frequency also correct if input has duplicates?
@deepanrajusugavasan9762
@deepanrajusugavasan9762 3 жыл бұрын
superb bro keep uploading⭐
@KnowledgeCenter
@KnowledgeCenter 3 жыл бұрын
Thanks.
@PEEYUSHKUMARPATHAK
@PEEYUSHKUMARPATHAK 3 жыл бұрын
Loved the explanation . Let's say we want to print the LCS, how would we achieve that? Would be interested in the java solution
@KnowledgeCenter
@KnowledgeCenter 3 жыл бұрын
Keep 2 more variables: int prev_max, next_max if ((next-prev-1) > res){ prev_max = prev; next_max = next; res = next-prev-1; } Finally print the sequence: prev+1, prev+2, ...., next-1.
@gokulnaathb2627
@gokulnaathb2627 9 ай бұрын
Just beautiful
@inspired_enough_to_grow_up
@inspired_enough_to_grow_up 2 жыл бұрын
map/ set creation will also take O(n log n) right?
@gokulnaathb2627
@gokulnaathb2627 9 ай бұрын
unordered_map or unordered_set creation will take only o(n) time if we want to insert n elements. map or set will take o(nlong)
@subee128
@subee128 5 ай бұрын
Thanks
@bestsaurabh
@bestsaurabh 3 жыл бұрын
Instead of unordered_set, we could have used unordered_map with O(1) lookup or it does not matter?
@navjot7397
@navjot7397 2 жыл бұрын
unordered set also has O(1) lookup (average)
@indiancseresearch6109
@indiancseresearch6109 2 жыл бұрын
thanks ;
@KnowledgeCenter
@KnowledgeCenter 2 жыл бұрын
You're welcome!
@syedabdul1228
@syedabdul1228 3 жыл бұрын
Arr=[values] Max=0 for i in Arr: Maxlen=1 n=i While n=n+1 in Arr Maxlen+=1 if Max
Leetcode 128 - LONGEST CONSECUTIVE SEQUENCE
9:24
NeetCode
Рет қаралды 390 М.
БУ, ИСПУГАЛСЯ?? #shorts
00:22
Паша Осадчий
Рет қаралды 2,9 МЛН
Ice Cream or Surprise Trip Around the World?
00:31
Hungry FAM
Рет қаралды 21 МЛН
Gas Station | LeetCode 134 | C++, Java, Python
23:02
Knowledge Center
Рет қаралды 32 М.
Coding Unbreakable Encryption in C | One-Time Pad
17:42
HirschDaniel
Рет қаралды 4,4 М.
Top 7 Data Structures for Interviews Explained SIMPLY
13:02
Codebagel
Рет қаралды 227 М.
New divisibility rule! (30,000 of them)
26:51
Stand-up Maths
Рет қаралды 281 М.
Time Based Key-Value Store | Leetcode 981
21:13
Knowledge Center
Рет қаралды 1,7 М.
Java Collections Explained (with examples)
10:39
Visual Computer Science
Рет қаралды 94 М.
БУ, ИСПУГАЛСЯ?? #shorts
00:22
Паша Осадчий
Рет қаралды 2,9 МЛН