Design a Hashset - LeetCode Interview Coding Challenge [Java Brains]

  Рет қаралды 78,242

Java Brains

Java Brains

Күн бұрын

Пікірлер: 74
@nishagandhewar8415
@nishagandhewar8415 4 жыл бұрын
Hi, are you planning for Design Patterns.. Looking forward to watch that playlist. Watched multiple videos of design patterns videos, but ur way of explaining is much better than those. Please do plan to crete one playlist for design patterns.
@natetolbert3671
@natetolbert3671 4 жыл бұрын
Hey Koushik. If you see this, I hope your day is going well. I just wanted to share an idea that I had for your channel. Wanted to run it by you to see what you think. You should add another "Join" tier/perk where members of said tier get to submit a topic of choice into a virtual submissions pool. Once a month (or weekly, bi-weekly, whatever you prefer) you draw a topic from the raffle and make a tutorial on it. Obviously, you would have to place constraints regarding acceptable content. I could see you benefiting greatly from this. If you were to implement a mid tier at ~$5, you would likely get quite a few new members. Especially if you decide to "shout out" the person whose topic is chosen in the resulting video. As an added bonus, you could spin a new series out of the ordeal. Off-the-cuff dev tutorials! I think these would likely end up being my favorite videos. IMPROV!!! I guarantee the audience response would be favorable. All in all, it seems like a win-win to me. It is at least worth trying out. I just came up with the idea, so, as far as I know, it is completely original on YT.
@sambit8011
@sambit8011 4 жыл бұрын
Please a video on Design a HashMap (as most of the interviews I'm getting the question "What is the internal of HashMap")...
@Artegentx
@Artegentx 4 жыл бұрын
this explanation qualifies for hashmap too, on how buckets are allocated
@saurabhbatheja
@saurabhbatheja 4 жыл бұрын
Just to help, the hashset internally uses a hashmap, with Object as value, it operates with the same principles just with a constant value because that isn't required obviously. BTW your name reminds me of someone, #justkidding :)
@therighteous802
@therighteous802 3 жыл бұрын
Space complexity on the simple solution is not O(n). Problem states there are at most 10k operations, so at most 10k adds, so n is 10k. But you'd be allocating way more than that.
@douglasharley2440
@douglasharley2440 4 жыл бұрын
it seems that the space complexity of the linkedlist implementation approaches O(N) as the number of elements approaches the max element count, and it still suffers from longer lookup times, so the advantage is lost with many elements. i guess the *real* advantage of that linkedlist implementation would be for situations when there aren't many elements...not to mention the fact that simple int key hashcode restricted to a short positive range is never seen irl, so an array of booleans is not realistic. xD as always, GREAT VIDEO! much thanks.
@bobby4320
@bobby4320 4 жыл бұрын
Hi sir, please do some series of tutorials of "collections " , waiting for your new collections playlist
@thekapila
@thekapila 11 ай бұрын
Hey there! I have really learnt a lot from the interview coding challenges and some of your other outputs. I am trying to obtain a role as a Java developer and have interviews set up. I have been through this entire playlist. Do you have another tips?
@chethan93
@chethan93 4 жыл бұрын
Awesome as always!! Koushik please make a playlist on design patterns..!!
@prakhar8690
@prakhar8690 6 ай бұрын
Awesome! I was asked this in an interview.
@uma_mataji
@uma_mataji 3 жыл бұрын
Thanks Koushik ,you really made it easy to understand the implementation of hashset .
@WhisperedWanders28
@WhisperedWanders28 4 жыл бұрын
Tutorial Request on: microservices communication using kafka
@payaltiwari9415
@payaltiwari9415 3 жыл бұрын
I m glad i came across your videos. Pls can you make videos for java for beginners too.. you hv all the content of hava just not the basics. Request to pls cover them too.
@nikolapetrovic4415
@nikolapetrovic4415 4 жыл бұрын
nice one
@basheeral-momani2032
@basheeral-momani2032 2 жыл бұрын
this is the second I see you, and Im happy to see you, keep the good work
@kumar29nov
@kumar29nov 4 жыл бұрын
Video Request: java 11 features introduced after java 8. Since it's the latest lts version would be good to know what's happening in Java world
@VarunVishwakarma1
@VarunVishwakarma1 3 жыл бұрын
As usual, simple and crisp. Please make videos on system design.
@vishnusudarsanam5375
@vishnusudarsanam5375 2 жыл бұрын
Should rehashing decrease the number of buckets and readjust the hash table accordingly if we perform too many remove operations?
@guruprasadmahapatro5172
@guruprasadmahapatro5172 4 жыл бұрын
Hi sir..I am a big fan of you, please do a tutorial on how the IT industry does continuous integration and continuous deployment of the spring boot application.
@teodora_cassualo
@teodora_cassualo 2 жыл бұрын
this man is everything
@aaaa1111222233331
@aaaa1111222233331 3 жыл бұрын
Hey nice explanation. How are you avoiding duplicates avoiding here?
@dowlathbashag65
@dowlathbashag65 4 жыл бұрын
Hello Kaushik, I hope you are doing good. Want to know how you are mapping with ipad with system. when you draw something. its showing simultaneously in the screen. Could you suggest how to do this.
@shahbazalam4565
@shahbazalam4565 3 жыл бұрын
Great explanation....Amazing. This channel certainly deserves more subscribers
@shekhar_2014
@shekhar_2014 4 жыл бұрын
Really a nice vdo.. Can youplease share a vdo on Memory management in JAVA sir ? It will be really helpful .
@bhanuagrawal8156
@bhanuagrawal8156 4 жыл бұрын
Please provide video on hashmap implementation, thanks.
@vyshnavramesh9305
@vyshnavramesh9305 4 жыл бұрын
Have been watching JB for 3 years now specificaly for Java. Started watching J2EE, Hibernate and Spring Boot playlists to get my first job, used the same for 2nd job. Then continued to microservices playlist for 3rd job now. For my 4th job, could you create playlists for Leetcode Top interview Qs and CTCI Chapter wise Qs? There are bits and pieces of these already online, but not even one is reliable to be the single point of contact. As an aspiring FAANG candidate, I hope I 'm raising the voices of many
@thainarodrigues4605
@thainarodrigues4605 2 жыл бұрын
I truly appreciate the explanation!
@rathan235
@rathan235 Жыл бұрын
Absolutely helpful
@galboss7673
@galboss7673 4 жыл бұрын
could you please make a video explaining how to make a Digest authentication with Jersey(JAX-RS) on java?
@hemaladani4510
@hemaladani4510 3 жыл бұрын
very simple explanation. Thank you so much!
@hemaladani4510
@hemaladani4510 3 жыл бұрын
Why not use ArrayList as child list and use LinkedList?
@ratneshchouhan6
@ratneshchouhan6 4 жыл бұрын
@javabrains Hi Koushik, another nicely explained video, However, I have another solution by just taking a cue out your array solution, in the array solution, The solution wasn't efficient because of space complexity but we can reduce it by using bit array of the highest limit this way we'll require only those many bits space and time complexity will also be of O(1). What do you think?
@ratneshchouhan6
@ratneshchouhan6 4 жыл бұрын
@Jorge Morando Yes , exactly👍 and the prob was not time complexity but the space one.
@techocean6372
@techocean6372 4 жыл бұрын
delightful video
@shruthis877
@shruthis877 4 жыл бұрын
Thanks for the beautiful explanation
@nagarajukp7820
@nagarajukp7820 4 жыл бұрын
Nice video. Thanks
@SoloGamer-23
@SoloGamer-23 4 жыл бұрын
Sir please upload videos on Node and express js ,Your content is amazing and I didn't find any other thoughtful tutorial on node js other then yours ,So please sir make video on Node and express
@Java.Brains
@Java.Brains 4 жыл бұрын
You should subscribe to my channel :) I already have many Node.js videos for you to watch and enjoy! As for Express, I'll work on it!
@RafiAhmedMangrio
@RafiAhmedMangrio 4 жыл бұрын
Please start a DSA series
@rinkeshgoyal1251
@rinkeshgoyal1251 4 жыл бұрын
How we can create a function to get the value at particular index which is send by user?
@nharshal
@nharshal 4 жыл бұрын
Need video series on design patterns
@douglasharley2440
@douglasharley2440 4 жыл бұрын
imo, design patterns just aren't that applicable for developers any more. generally, the system architecture is defined by whatever well-established framework you are using, so a system implementation is primarily just business logic leveraging the framework(s). obviously, the story is very different if you are building a framework, or server or something like that, from-scratch, and you'll need to make use of plenty of patterns, but that's just not something the average developer needs to concern themselves with in their actual job. it's much more important to stay abreast of the explosion of frameworks, and platforms, and services, and apis, and languages, and protocols, and...lol, just the topic of javascript front-end build tools (NPM, Gulp, Grunt, Webpack, etc.) is already daunting, and getting more so all the time! GoF just isn't really relevant to software anymore i'd argue. peace
@techocean6372
@techocean6372 4 жыл бұрын
@@douglasharley2440 you are right , design patterns ,configuring logs,config files all are made easy in frameworks .
@shubhampatel7870
@shubhampatel7870 4 жыл бұрын
21:50 what if the key is not present but the childList is not null. It contains some other element. I think we should handle that case as well? e.g. 1001%100 = 1 but the bucket 1 contains 1901 which can be in the same bucket due to collisions. Am I missing something?
@jimmymehta5237
@jimmymehta5237 4 жыл бұрын
that is good to have but lets say 1901 in bucket 1 and 1001 remove comes , so we'll remove 1001 (which dont exist) ,so no effect.I mean it will not have any problem.
@vivekmuralidharan4913
@vivekmuralidharan4913 4 жыл бұрын
I love your videos. Thanks a lot for posting them. I have a query. In the list solution, while adding an element, it is being checked with only a specific bucket obtained of the hashed index. What if the element is already present in another bucket and never being checked? Wont that create duplicate elements to hashset which is contrary to behavior of hashset?
@veipuniilana1842
@veipuniilana1842 3 жыл бұрын
that is not possible i guess, becuase hash function is same for all the key, so whenever you enter the key it will go to that particular backet you just entered before.
@WanderWithWadhera
@WanderWithWadhera 4 жыл бұрын
great dude.. it very simple to understand 👍🏻👏🏻
@AjayKumar-fd9mv
@AjayKumar-fd9mv 4 жыл бұрын
Great
@ashishkumarsingh6618
@ashishkumarsingh6618 Жыл бұрын
Why you didn't use MAX_VALUE mentioned as instance variable
@adityaverma1172
@adityaverma1172 4 жыл бұрын
I was asked this question in an interview, I too used ArrayList but he clearly said that we cannot use any existing library to implement it. So can we implement this using simple array or some custom DS.
@tarunkumargola7633
@tarunkumargola7633 3 жыл бұрын
Can you tell me how you implemented it without any existing library?
@danthe1st
@danthe1st 4 жыл бұрын
Just wrap HashMap, that is how HashSet works. It is not using HashSet ;) It is not even using a Set
@anandgupta8529
@anandgupta8529 4 жыл бұрын
shut up
@balakrishnanu2061
@balakrishnanu2061 4 жыл бұрын
What Dan said is true. As I remember, Hashset in Java is Hashmap of type or so. There would be a key which is Hashset value, but no value in the map.
@danthe1st
@danthe1st 4 жыл бұрын
The key and the value is the same if I remember correctly but I am not sure.
@danthe1st
@danthe1st 4 жыл бұрын
If you look at the sources of HashSet(OpenJDK: github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/util/HashSet.java), you can clearly see that it uses a HashMap where a reference to a new Object (constant) is used for all values present.
@balakrishnanu2061
@balakrishnanu2061 4 жыл бұрын
@@danthe1st Ah, yes. So it's a blank object. I remember something constant was used. It's not null. 😅 Guess its time to start again, it's been more than 2 years since I wrote a program in Java.
@jimmymehta5237
@jimmymehta5237 4 жыл бұрын
I am using above code and in leetcode it is failing for one of the test case. After debugging, find out that, when I add 48 first time, it is creating index 48 and add on that. when i check contains(48) then it returns NULL, and i debug it and saw it that it stores at index 49, Is it because we used ArrayList and it is 0 based index?
@harshbiyani3048
@harshbiyani3048 4 жыл бұрын
Use set() instead of add when adding the childList to parentList.
@parasghai28
@parasghai28 3 жыл бұрын
@@harshbiyani3048 my test case was also failing but replacing add with set worked. But I didt understand why
@yoshifan102
@yoshifan102 Жыл бұрын
I had the same problem
@naughtynawaz
@naughtynawaz 4 жыл бұрын
Make a video on map and thread plzz
@vishalgupta9156
@vishalgupta9156 3 жыл бұрын
Didn't you take care to not add duplicates in hashset ?
@theswarajdeshmukh
@theswarajdeshmukh 4 жыл бұрын
like before watching it ...
@sivakrishnat5471
@sivakrishnat5471 2 жыл бұрын
what is the point of this interview question? isn't it reinventing the wheel?
@JohnDoe-ej6vm
@JohnDoe-ej6vm 2 жыл бұрын
You did not use this MAX_VALUE any where in the code then what was the purpose of its declaration ? private final int MAX_VALUE = 1000000;
@chaitanyatanwar8151
@chaitanyatanwar8151 4 жыл бұрын
Thank you!
@kumar29nov
@kumar29nov 4 жыл бұрын
LPT: Simple implementation is like a programming joke. do not seriously give that to interviewer as final solution, you can joke about it, but not as final solution. ;) Because the main problem "Hash" concepts solve is lack of sequential memory. It aims to strike a balance between lack of sequential memory in array implementation and having to traverse through all values in linked list
@amrholo4445
@amrholo4445 2 жыл бұрын
Thanks a lot, sir
@alxx736
@alxx736 3 жыл бұрын
Why LinkedList and not List?
Detect Capital - LeetCode Interview Coding Challenge [Java Brains]
25:09
Why no RONALDO?! 🤔⚽️
00:28
Celine Dept
Рет қаралды 54 МЛН
FOREVER BUNNY
00:14
Natan por Aí
Рет қаралды 25 МЛН
ТЫ В ДЕТСТВЕ КОГДА ВЫПАЛ ЗУБ😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 4,5 МЛН
Map and HashMap in Java with Internal Working- Interview Question
19:27
Daily Code Buffer
Рет қаралды 30 М.
Design HashSet - Leetcode 705 - Python
11:57
NeetCodeIO
Рет қаралды 24 М.
Java HashSet Tutorial
20:30
Coders Campus
Рет қаралды 88 М.
How Senior Programmers ACTUALLY Write Code
13:37
Thriving Technologist
Рет қаралды 1,6 МЛН
What is JWT? JSON Web Tokens Explained (Java Brains)
14:53
Java Brains
Рет қаралды 1 МЛН
Set and HashSet in Java - Full Tutorial
20:43
Coding with John
Рет қаралды 232 М.
Design HashSet | EP 8
24:31
Fraz
Рет қаралды 32 М.