Noob Software Engineer vs O(n) Swaggy Engineer on Counting Elements, Leetcode 1426

preview_player
Показать описание
FAANG Coding Interviews / Data Structures and Algorithms / Leetcode
Рекомендации по теме
Комментарии
Автор

Master Data Structures & Algorithms For FREE at AlgoMap.io!

GregHogg
Автор

Absolutely love these clips. keep em coming

jameslockwood
Автор

...
I'm solving LeetCode with C
Each time one of these coding bros pulls out the hashSet/hashMap I get an existential crisis
(because I have to make one myself... oof)
(sometimes you can cheese it by just making the array large enough, based on the upper/lower bounds provided by the problem desc, then it gets easier and the hashFunction can remain simple.)

nar
Автор

Thank god i saw your video right now... Had almost forgotten about my streak today 😭

imnotaburrito
Автор

Using that solution you are ignoring duplicate values, am I wrong?

beransantur
Автор

s = set(arr) is O(n) in itself. I think there is no overall change as you are doing the hard work before the loop. Tell me if this isn't the case.

shahbazsingh
Автор

Kabhi kabhi lagta h, ki coding karte karte kahi me bhi iske jaisa na ho jau😢😢

moviestownhd
Автор

wtf was that, yeah, I need to relearn data structure

shiro_asa
Автор

But space complexity got increased from O(1) to O(N)

the.comedypie
Автор

It seems like there's a glitch on leetcode, Even if you resubmit the same solution it somehow improves the code's runtime!!

rishabhshukla
Автор

What platform do you solve these questions on ?

ערןאוצפ
Автор

I ve got a better approach

for i in range(len(array)):
if array[0] + i !=array[i]:
return False
return True

aashishnegi
Автор

for the first time, I took a glance at the actual video of you "talking". never again.

malou
Автор

Why don't you use some low-level like C language?

thegamingflow
Автор

I would put the list into a Counter, then sum over the counts for values whose successor is present.

counter = Counter(arr)
return sum(count for (value, count) in counter.items() if value + 1 in counter)

alxjones
Автор

is his mouth even moving or is this a full voiceover lol

marcialabrahantes