This Easy FAANG Interview Question is AWESOME! | Contains Duplicate II - Leetcode 219

preview_player
Показать описание
dynamic programming, leetcode, coding interview question, data structures, data structures and algorithms, faang
Рекомендации по теме
Комментарии
Автор

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

GregHogg
Автор

Greg you the goat. Always clear and to the point

wildfan
Автор

Thanks man. I'm learning a lot from you. Just love your videos.

dantemix
Автор

What about having set with k last elements?
It would reduce space complexity from O(n) to O(k) - it makes especially sense if k is much smaller than n

Removing i-k element from set after doing set will make the job.

mateuszobrzut
Автор

Nice, I like that solution a lot, all I could think of was brute force

tamemister
Автор

I am just a beginner greg but still your videos motivates me to learn more keep going!!

bssandeep
Автор

hashmap, the answer to all interview questions

UncleJemima
Автор

Do you need the abs? Won't the index stored in the map always be less than the next hit? Or am I tripping

efthymew
Автор

Is there a shorter way?
As someone who struggles a lot can’t I just do something like:
for i in range(arr):
if int(arr)**2: return True
else:
False

Wladyslaw
Автор

A sliding window: O(N-k)
var max = nums.length - k;
for(var i = 0; i < max; i++)
if (nums[i]==nums[i+k])
return true;
return false;

casperhansen
Автор

Can I hear why just comparing for every element - distance for array[i] and aray[i+k] is bad idea?

SekaReal
Автор

Brother with js we can learn DSA its easy are complex??

TheViral_fyp
Автор

better. You have a queue and you store only k values.

Saheryk
Автор

Like in the anime, the hero can arrive in City 1 with a skill index of 0 or a skill index of 4. Then, the hero can leave City 1 with a skill index of 0 or a skill index of 4. Switch on, Switch off. Forward and backward.

xingyuxiang
Автор

As a competitive programmer, this is laughable, also, I can make your code exceed the time limit as the default hashmap doesn’t have the best hash function

ismailseif
join shbcf.ru