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
I thought one thing and the truth is something else 😂
00:34
عائلة ابو رعد Abo Raad family
Рет қаралды 5 МЛН
Увеличили моцареллу для @Lorenzo.bagnati
00:48
Кушать Хочу
Рет қаралды 8 МЛН
The Singing Challenge #joker #Harriet Quinn
00:35
佐助与鸣人
Рет қаралды 44 МЛН
Top 7 Data Structures for Interviews Explained SIMPLY
13:02
Codebagel
Рет қаралды 227 М.
Leetcode 128 - LONGEST CONSECUTIVE SEQUENCE
9:24
NeetCode
Рет қаралды 390 М.
Partition Array into Disjoint Intervals | LeetCode 915 | C++, Java, Python
20:13
Longest Increasing Subsequence | Binary Search | Leetcode 300
24:30
Knowledge Center
Рет қаралды 1,1 М.
Longest Consecutive Sequence | Leetcode 128 | Hashset
12:38
Ayushi Sharma
Рет қаралды 12 М.
Leetcode 128 Longest Consecutive Sequence - Python Solution
7:29
Data Engineering Studies
Рет қаралды 378