Two Sum (LeetCode #1) | 3 Solutions with animations | Study Algorithms

  Рет қаралды 72,183

Nikhil Lohia

Nikhil Lohia

Күн бұрын

Пікірлер: 94
@nikoo28
@nikoo28 3 жыл бұрын
At 12:58, I am supposed to add "8" to the hash table and not "11". Sorry for the error.
@atharvalaad8926
@atharvalaad8926 Ай бұрын
😅😅😅😅😅😅😅 15:52 😅😅😊😅😅😅 15:52 15:52 15:52 15:52 15:52 😅 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 😅 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 15:52 😅 15:52 15:52 15:52 15:52 15:52 15:52 15:52
@halimaomar9820
@halimaomar9820 2 жыл бұрын
This is absolutely the best explanation on KZbin. Everyone else goes straight to coding and doesn't break down the logic beforehand.
@nikoo28
@nikoo28 2 жыл бұрын
Happy that I could help :)
@AKASH-fe6vy
@AKASH-fe6vy 14 күн бұрын
So nice of you to put this in a simple yet insightful manner, thanks a lot.
@billyfigueroa1617
@billyfigueroa1617 7 ай бұрын
Excellent content. This is the second video I watch which allows one to be able to devise a nicer solution simply by sorting the array. The hash map solution is genius and is not complicated I will now, always look at a problem and find out how I can solve it by first thinking "Would sorting this array help to simplify the solution"
@nikoo28
@nikoo28 7 ай бұрын
Awesome, thank you!
@billyfigueroa1617
@billyfigueroa1617 7 ай бұрын
@@nikoo28 you are welcomed
@ayushtalks2.0
@ayushtalks2.0 2 жыл бұрын
One of the best way of teaching . Sir Keep posting more videos of dsa. 👍👍
@nikoo28
@nikoo28 2 жыл бұрын
Thank you so much for your support :)
@Spear_of_Boudicca
@Spear_of_Boudicca 14 күн бұрын
Good video, very similar to my university lectures. I think the reason a lot of people fail to learn some things on their own is that they just see code and want to understand it magically, you need to get the logic behind stuff.
@wenkaiyang1487
@wenkaiyang1487 11 ай бұрын
thank you soooo much! I checked out so many videos about this question. finally your video helped me out! firmly subscribed to your channel
@aman_rockstar31
@aman_rockstar31 2 ай бұрын
you r really an excellent teacher one thing i want to tell ur explanation is better that striver thanks for providing such videos
@Karan-ow4wl
@Karan-ow4wl 7 күн бұрын
Best Video Explanation so far !!!
@Rockstar-16
@Rockstar-16 2 жыл бұрын
Sir😄, I have no words, I have never seen anyone explain this nicley, thank you so much❤
@nikoo28
@nikoo28 Жыл бұрын
Thank you so much for your kind words.
@harihardhik3293
@harihardhik3293 Жыл бұрын
Such a great way of explaining this problem. You have redefined teaching sir!!! Amazing Work!!!!
@nikoo28
@nikoo28 11 ай бұрын
Thanks a ton
@yowanehakuuu
@yowanehakuuu Жыл бұрын
I watched two other videos before coming here , to be honest you are the best one . I only understand from you because other people talk too long without explaining they talk about the problem not the solution. You even taught me the math side of this . Thank you , I subscribed. I will watch the rest of the solutions
@nikoo28
@nikoo28 11 ай бұрын
I prefer to focus on the problem. Language is a tool anyway, and they will keep changing and evolving. Thanks for the sub!!
@bobbysokhi7296
@bobbysokhi7296 2 ай бұрын
Underrated channel.
@sarthakgadge5223
@sarthakgadge5223 2 ай бұрын
Thanks a lot, I was able to understand this problem thanks to your efforts.
@sahilhansofficial
@sahilhansofficial Жыл бұрын
Love the way you teach, TYSM☺
@elizabeth00653
@elizabeth00653 4 ай бұрын
Thank you for taking the time to create this video and make a clear explanation
@pooja3711
@pooja3711 9 ай бұрын
you are the best.I really appreciate your hard work and step-by-step approach to how to overcome with a solution. Hats off
@nikoo28
@nikoo28 9 ай бұрын
thanks for the appreciation and motivation :)
@brahmithegod9558
@brahmithegod9558 2 жыл бұрын
I was searching for the solution but do not found dryryn but u did it thank bro ❤️
@shacks-b3b
@shacks-b3b 8 ай бұрын
Please keep uploading DSA/leetcode videos, they all are really helpful, thanks!
@nikoo28
@nikoo28 7 ай бұрын
More to come!
@KaisarAnvar
@KaisarAnvar Жыл бұрын
You're by far the most detailed explainer I've seen. I've seen a few, but you're really amazing. Having a coding interview soon.
@nikoo28
@nikoo28 Жыл бұрын
All the very best for your upcoming interviews :)
@joshuajacobs6855
@joshuajacobs6855 Жыл бұрын
Only just got into coding a few days ago coming from a teacher background. Great explanations!
@RajKumar-li8dc
@RajKumar-li8dc Жыл бұрын
Best way to teach sir plz discuss more question and make a proper playlist ❤❤❤
@nikoo28
@nikoo28 Жыл бұрын
Check out my playlists in the channel :)
@kishanbhadoriya8701
@kishanbhadoriya8701 9 ай бұрын
Thank you very much, finally understood
@bivinnandhu781
@bivinnandhu781 Жыл бұрын
Thank you bro you do grate things your explanation is very simple and easy to understand Iam so happy to see this video
@nikoo28
@nikoo28 Жыл бұрын
so happy to read this
@japaneseger
@japaneseger 2 жыл бұрын
You explained it very well, best video out there regarding this solution!!"!!!!
@TV-wk7oo
@TV-wk7oo Жыл бұрын
Thank you, you are the best! Visualizing the code helped me a lot
@nikoo28
@nikoo28 Жыл бұрын
You're welcome!
@1tav0
@1tav0 2 жыл бұрын
Thank you for the video it really helped me!
@girdharipatel2
@girdharipatel2 Жыл бұрын
your explanation is for more better than other youtuber
@nikoo28
@nikoo28 Жыл бұрын
Glad you feel that way :D
@206_dindayalpatra3
@206_dindayalpatra3 6 ай бұрын
Thank you ❤
@malkitsaggu
@malkitsaggu 2 ай бұрын
Best explanation 👌
@coldcases_2
@coldcases_2 14 күн бұрын
sir @nikoo28 ,there is a mistake in two pointer approch i think where if => num1 and num2 are the same (e.g., nums = [3,3], target = 6), so code will return the same index for both numbers, especially if there are duplicates in the original array. for ex nums = [3,3] target = 6 Output [1,1] Expected [0,1] which is wrong so should we apply something else here?
@dineshpatil6698
@dineshpatil6698 2 жыл бұрын
such clear explantion , subscribed
@AbhishekRamola-u7y
@AbhishekRamola-u7y 3 ай бұрын
Kudos! Great explanation brother.P.s: Bro, you sound exactly like Pennywise from It.
@pulastyadas3351
@pulastyadas3351 2 жыл бұрын
awesome explanation..keep teaching us
@manjunathakaliwalLife_Atlanta
@manjunathakaliwalLife_Atlanta 8 ай бұрын
Good one
@aniketpurohit7601
@aniketpurohit7601 8 ай бұрын
Amazing
@prakharpathak5899
@prakharpathak5899 Жыл бұрын
Very smooth sir
@sanjeewagunarathna1990
@sanjeewagunarathna1990 2 жыл бұрын
Great video best explanation
@AkaNuclear
@AkaNuclear 5 ай бұрын
For the second solution where we are using hashmap, the time complexity of finding an element is also O(n) in case of hash collisions
@nikoo28
@nikoo28 5 ай бұрын
For a very big input size, yes there will be collisions…but for the domain of this problem you should be just fine. Good to discuss this with your interviewer though 😄
@kunalkheeva
@kunalkheeva 2 жыл бұрын
thank you for a great explanation, what would be its space complexity?
@nikoo28
@nikoo28 2 жыл бұрын
Which solution do you want the space complexity for? :)
@04.nehalsingh12
@04.nehalsingh12 2 жыл бұрын
awesome tutorial sir
@anchalsoni8614
@anchalsoni8614 3 жыл бұрын
awesome video... keep making them
@juledoc_07
@juledoc_07 Жыл бұрын
I had a question about the tastable, 19-4 is 15, but it is on the table so why don't we stop there? Thank you
@Samtoosoon
@Samtoosoon 4 ай бұрын
Best
@jst8922
@jst8922 8 ай бұрын
06:03 - Method 1: Using Sorting This is basically sliding window solution, when you have two pointers , left and right and you move them correspondingly.
@dipanwitasahoo6643
@dipanwitasahoo6643 6 ай бұрын
Is this possible using binary search?
@lipovgaming7245
@lipovgaming7245 29 күн бұрын
but how do you return 2 elements.
@sunnyrajesh
@sunnyrajesh 5 ай бұрын
Hello I have a small doubt ? How we return two index values here map.get(complement),i); Can any one explain 🤔 does it return complement index and current I value ?
@im_andre6dev56
@im_andre6dev56 10 ай бұрын
Hi Nikhil, what program do you use to draw the solution?
@nikoo28
@nikoo28 9 ай бұрын
GoodNotes 6
@Programming-for-all-u2l
@Programming-for-all-u2l 8 ай бұрын
I do not know why he gets very few likes and he is the best teacher for explaining the leetcode problems
@nikoo28
@nikoo28 7 ай бұрын
so happy you believe in me. Please share the videos if possible. Trying my best with SEO to get ranked up in search results.
@ashishsonii
@ashishsonii Ай бұрын
Brother don't stop making leetcode questions​@@nikoo28
@ganesang7217
@ganesang7217 10 ай бұрын
its cool
@ymhuang651
@ymhuang651 2 жыл бұрын
Awesome channel! Why I Find it so late?
@nikoo28
@nikoo28 2 жыл бұрын
Glad I could help you 😄
@karthik-varma-1579
@karthik-varma-1579 6 ай бұрын
AT 10:31 the method is not working for negative numbers in the array;
@nikoo28
@nikoo28 6 ай бұрын
the optimized method takes care of all different test cases
@karthik-varma-1579
@karthik-varma-1579 6 ай бұрын
@@nikoo28 Ohk Thanks Sir
@sushant3530
@sushant3530 2 жыл бұрын
Sir will 3rd Method will work if array has Duplicate elements . Becoz in HashMap , the key cannot be duplicate. And if array elements repeats , they duplicate key is found. PLZZZZ PLZZ EXPLIAN THIS SIR
@nikoo28
@nikoo28 2 жыл бұрын
since the problem says you will have EXACTLY ONE SOLUTION, you do not need to worry about duplicate number. Because if a duplicate number exists, then you will have 2 possible solutions...and hence that is not a valid scenario.
@ashishkumaryadav7701
@ashishkumaryadav7701 Жыл бұрын
@@nikoo28 but in the example there is repetitive element
@RapJunkie
@RapJunkie 3 ай бұрын
@@nikoo28 we have a valid scenario [3,3], and this method won't work :(
@powerball200
@powerball200 Жыл бұрын
bro plz do in python
@shwetamandal6616
@shwetamandal6616 Жыл бұрын
what is this """'' return new int[]{map.get(complement),i}; """" ? as it throws error and i am getting you've used curly brackets with new int[]...................please reply..........................
@nikoo28
@nikoo28 Жыл бұрын
It gets the complement pair and then returns it as an array.
@IorgaArtStudio
@IorgaArtStudio 3 жыл бұрын
subbed!
@kashmirviews4332
@kashmirviews4332 5 ай бұрын
Can anybody tell how to write the main function code for the same function.
@nikoo28
@nikoo28 5 ай бұрын
Just create an object of the class and call it in the main method
@kashmirviews4332
@kashmirviews4332 5 ай бұрын
@@nikoo28 thanks.
@ME022GopinathanAsokan
@ME022GopinathanAsokan 9 ай бұрын
sir what language you are used here
@nikoo28
@nikoo28 9 ай бұрын
Java
@ashishsonii
@ashishsonii Ай бұрын
Dont stop DSA questions
@abhinavd2
@abhinavd2 Жыл бұрын
100
@YNKeerthi-ry6jx
@YNKeerthi-ry6jx 6 ай бұрын
koko eating banana 875 leetcode question
@nikoo28
@nikoo28 5 ай бұрын
It is available now: kzbin.info/www/bejne/gHi8iYGmj8aKaLcsi=2ftslOTD1LCE8-r2
规则,在门里生存,出来~死亡
00:33
落魄的王子
Рет қаралды 29 МЛН
OYUNCAK MİKROFON İLE TRAFİK LAMBASINI DEĞİŞTİRDİ 😱
00:17
Melih Taşçı
Рет қаралды 13 МЛН
GIANT Gummy Worm Pt.6 #shorts
00:46
Mr DegrEE
Рет қаралды 129 МЛН
Spongebob ate Patrick 😱 #meme #spongebob #gmod
00:15
Mr. LoLo
Рет қаралды 22 МЛН
10 Math Concepts for Programmers
9:32
Fireship
Рет қаралды 1,9 МЛН
How to Solve ANY LeetCode Problem (Step-by-Step)
12:37
Codebagel
Рет қаралды 248 М.
Amazon Question | LeetCode 1. Two Sum | Tamil | code io
10:52
code io - Tamil
Рет қаралды 28 М.
5 Math Skills Every Programmer Needs
9:08
Sahil & Sarra
Рет қаралды 1,1 МЛН
LeetCode Exercise in Java Tutorial - Two Sum FAST Solution
23:36
Coding with John
Рет қаралды 186 М.
规则,在门里生存,出来~死亡
00:33
落魄的王子
Рет қаралды 29 МЛН