Design HashMap | Live Coding with Explanation | Leetcode - 706

  Рет қаралды 24,205

Algorithms Made Easy

Algorithms Made Easy

Күн бұрын

Пікірлер: 44
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 жыл бұрын
We hope you all are enjoying our videos!!! Don't forget to leave a comment!!! Please like the video to support us!!! Questions you might like: ✅✅✅[ Tree Data Structure ] : kzbin.info/aero/PLJtzaiEpVo2zx-rCqLMmcFEpZw1UpGWls ✅✅✅[ Graphs Data Structure ] : kzbin.info/aero/PLJtzaiEpVo2xg89cZzZCHqX03a1Vb6w7C ✅✅✅[ February Leetcoding Challenge ] : kzbin.info/aero/PLJtzaiEpVo2wrfvII0eZQsPm-MZCmHodm ✅✅✅[ January Leetcoding Challenge ] : kzbin.info/aero/PLJtzaiEpVo2wCalBcRcNjXQ0C6ku3dRkn ✅✅✅[ December Leetcoding Challenge ] : kzbin.info/aero/PLJtzaiEpVo2xo8OdPZxrpybGR8FmzZpCA ✅✅✅[ November Leetcoding Challenge ] : kzbin.info/aero/PLJtzaiEpVo2yMYz5RPH6pfB0wNnwWsK7e ✅✅✅[ August Leetcoding Challenge ] : kzbin.info/aero/PLJtzaiEpVo2xu4h0gYQzvOMboclK_pZMe ✅✅✅July Leetcoding challenges: kzbin.info/aero/PLJtzaiEpVo2wrUwkvexbC-vbUqVIy7qC- ✅✅✅June Leetcoding challenges: kzbin.info/aero/PLJtzaiEpVo2xIfpptnCvUtKrUcod2zAKG ✅✅✅May Leetcoding challenges: kzbin.info/aero/PLJtzaiEpVo2wRmUCq96zsUwOVD6p66K9e ✅✅✅Cracking the Coding Interview - Unique String: kzbin.info/aero/PLJtzaiEpVo2xXf4LZb3y_BopOnLC1L4mE Struggling in a question?? Leave in a comment and we will make a video!!!🙂🙂🙂
@SurajSingh-tz1wr
@SurajSingh-tz1wr 3 жыл бұрын
This video is so self-explanatory and the solution is so clean. Loved this video. Thanks a lot!
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 жыл бұрын
Thanks !!
@satheshbm92
@satheshbm92 2 жыл бұрын
The clearest explanation, I found for the problem. Great work :)
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 2 жыл бұрын
Glad it helped!
@yusufazam1113
@yusufazam1113 2 жыл бұрын
If I am not mistaken this solution is technically incorrect, as the problem states you must insert a key value pair. In this case the solution only stores the value and uses the key for indexing purposes only.
@pritisharma8980
@pritisharma8980 2 жыл бұрын
very clear and concise explanation,and in a short video,thanks for posting
@AnkitKumar-ys7vs
@AnkitKumar-ys7vs 6 ай бұрын
Thanks
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 6 ай бұрын
Welcome
@fantasy9960
@fantasy9960 Жыл бұрын
best of the best! thank you for your effort !
@codedestiny6955
@codedestiny6955 3 жыл бұрын
Keep learning keep coding
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 жыл бұрын
yes 👍 😊
@abcdeereijgfhd3215
@abcdeereijgfhd3215 3 жыл бұрын
This is the clearest explanation I have found so far. Thank you. BTW your typing speed is unrealistic. Did you fast-forward the video or just have the fastest finger? haha~!
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 жыл бұрын
Thank you so much! Haha.. I fast forward. 🙂
@YNA64
@YNA64 3 жыл бұрын
Hello thanks for the video. I have a question regarding the time complexity being O(1). Why is that so? Should it not be O(n) because for each method, in the worst case, you will have to traverse through a whole list? Hope you could clarify, thank you.
@shreyamduttagupta7527
@shreyamduttagupta7527 3 жыл бұрын
Even I had the same question. For best case scenario, the put method will have O(1) time complexity if the key is not available, but if it exists, it will have to iterate through the whole bucket to find the key and update. I feel the time complexity should be O(N/K) where N is the number of keys and K is the Size taken which is 769. Let me know what you think!
@trevorjomeihoshiwara2961
@trevorjomeihoshiwara2961 2 жыл бұрын
I agree about your assessment in the worst case scenario. I believe it should have been stated as O(1) time complexity amortized. On average with a properly implemented HashMap, entries, deletions, and searches should execute in constant time. This all relies on the fact that there is a reasonable load factor (The size of the hashing array vs. the number of elements to be inserted).
@xinniu3145
@xinniu3145 2 жыл бұрын
Thanks for sharing this answer, could anybody explain why the time complexity is O(1)? and why space complexity is O(N)? And also, at 4:18, why size of 769 makes the hashing efficient? Thank you!
@iliasolovev266
@iliasolovev266 3 жыл бұрын
Why did we use toRemove variable? Why just we din't remove in right there like map[bucket].remove(entry)? Because it can cause ConcurrentModificationException?
@ujjvalsharma5055
@ujjvalsharma5055 3 жыл бұрын
Wonderful video!! Keep making great videos
@prachiraval4728
@prachiraval4728 3 жыл бұрын
How to print the final map after giving put and get method
@ammarshareef462
@ammarshareef462 3 жыл бұрын
How are we solving the issue of collisions in this problem.
@sase1017
@sase1017 3 жыл бұрын
pretty awesome, thanks!
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 2 жыл бұрын
Most welcome!! Don't forget to subscribe!!! :)
@ashwanisingh4787
@ashwanisingh4787 2 жыл бұрын
Why are we creating Entry class.Can u plz explain
@sanyamgoel1259
@sanyamgoel1259 3 жыл бұрын
Can we do using simple array?
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 жыл бұрын
Yes, we can do it. But that would not represent the actual implementation. We have shown that too in the video.
@sammedsankonatti9642
@sammedsankonatti9642 3 жыл бұрын
why do we use Entry object to iterate like for(Entry entry : map[bucket]). didn't get that.
@tusharjain7433
@tusharjain7433 2 жыл бұрын
map[bucket] is the linked list have a type of entry objects
@dhruvkaran9724
@dhruvkaran9724 2 жыл бұрын
in remove when we found our key y we did not break; ???
@rechinraj111
@rechinraj111 3 жыл бұрын
Why have we choosen SIZE as 769 ?
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 жыл бұрын
you can choose any arbitrary value!! usually, we try to select a large prime number!
@rechinraj111
@rechinraj111 3 жыл бұрын
@@AlgorithmsMadeEasy why only PRIME nos?
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 жыл бұрын
not only prime numbers. you can select any number. prime numbers give us less collision so that's a recommended practice.
@rashmikiranpandit8962
@rashmikiranpandit8962 3 жыл бұрын
For both the methods, the space used was almost the same, I wonder why did we use so complex method then
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 жыл бұрын
The complex method is more in line with what an actual hashmap works on. It is discussed by keeping the interviewer in mind.
@ramkumar_balu
@ramkumar_balu 3 жыл бұрын
Why array of LinkedList? Can it be another DS?
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 жыл бұрын
If you see the internal working of HashMap. You will find, it used array of LinkedList.
@harishreddy7751
@harishreddy7751 3 жыл бұрын
This solution is good but I'm 100% sure the follow up question would be on collision which was not handled here and needs to be handled
@shreyamduttagupta7527
@shreyamduttagupta7527 3 жыл бұрын
What do you mean? I think she explain collision and the reason of 769. She is using Modulo operator to calculate hashCode and a larger prime number to handle Collison. Isn't that enough? Let me know what you think!
@nishantchoudhary5073
@nishantchoudhary5073 Жыл бұрын
your solution in this video are not working
@lokeshsenthilkumar4522
@lokeshsenthilkumar4522 3 жыл бұрын
Awesoom try to post the video before 5pm pls
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 жыл бұрын
Hi Lokesh, KZbin channel is not the primary job to us. We have our regular offices and can't make videos in office time. So you would see the delay. Hope you understand.
@luminraja09
@luminraja09 6 ай бұрын
kzbin.info/www/bejne/f4TMo2VmbLeogbM is this the special case to handle the collision ?
Simplify Path | Live Coding with Explanation | Leetcode - 71
11:08
Algorithms Made Easy
Рет қаралды 10 М.
Design HashMap | leetcode 706
17:51
Tech Adora by Nivedita
Рет қаралды 3,7 М.
This Game Is Wild...
00:19
MrBeast
Рет қаралды 185 МЛН
МЕНЯ УКУСИЛ ПАУК #shorts
00:23
Паша Осадчий
Рет қаралды 5 МЛН
Noodles Eating Challenge, So Magical! So Much Fun#Funnyfamily #Partygames #Funny
00:33
G2 on 5G: 6G AI Trials, Qualcomm IoT, Aramco Rumors, Nokia Wins, CV2X, RFK Jr. Concerns
27:40
G2 on 5G Podcast by Moor Insights & Strategy
Рет қаралды 8
Implementing Your Own HashMap (Explanation + Code)
26:59
Random Coder
Рет қаралды 28 М.
Short Encoding of Words | Live Coding with Explanation | Leetcode - 820
17:27
Design Underground System | Live Coding with Explanation | Leetcode - 1396
13:26
Design HashMap | LeetCode 706 | C++, Java, Python
13:41
Knowledge Center
Рет қаралды 16 М.
Design Hashmap - Leetcode 706 - Python
14:30
NeetCodeIO
Рет қаралды 36 М.
Binary Tree Cameras | Live Coding with Explanation | Leetcode - 968
13:15
Algorithms Made Easy
Рет қаралды 10 М.
This Game Is Wild...
00:19
MrBeast
Рет қаралды 185 МЛН