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

preview_player
Показать описание

Two Sum is a programming question on LeetCode and very important for interviews. You are given an array of integers and a target value as the input. There are exactly two integers in the array which add up to the target value. You are required to return the indices of these 2 integers. Watch this video to learn 3 ways of solving this problem. You will learn a brute force solution, a solution using sorting, and a solution using Hash-map. Each of the solution has been explained with step by step animations and with a dry-run of the code so that it sticks in your mind forever.

00:00 - Intro
01:07 - Problem statement and description
03:54 - Brute Force Method
06:03 - Method 1: Using Sorting
10:36 - Method 2: Using Hash-Map
14:04 - Dry-run of code
16:35 - Final thoughts

📚 Links I talk about in the video:

💻 Get Social 💻

#leetcode #programming #interview
Рекомендации по теме
Комментарии
Автор

At 12:58, I am supposed to add "8" to the hash table and not "11".
Sorry for the error.

nikoo
Автор

This is absolutely the best explanation on Youtube. Everyone else goes straight to coding and doesn't break down the logic beforehand.

halimaomar
Автор

this is my favourite channel for solving leetcode problems, i'm from Vietnam, thank you guy a lot

GHT
Автор

So nice of you to put this in a simple yet insightful manner, thanks a lot.

Akash_XDD
Автор

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"

billyfigueroa
Автор

thank you soooo much! I checked out so many videos about this question. finally your video helped me out! firmly subscribed to your channel

wenkaiyang
Автор

Sir😄, I have no words, I have never seen anyone explain this nicley, thank you so much❤

Rockstar-
Автор

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.

Spear_of_Boudicca
Автор

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

yowanehakuuu
Автор

Bro you are just awesome.The best explanation so far. I am new to programming. It always scared to even touch leetcode, came across your channel somehow.. you just made it look so easy

Padmak-wl
Автор

One of the best way of teaching . Sir Keep posting more videos of dsa. 👍👍

ayushtalks.
Автор

Such a great way of explaining this problem. You have redefined teaching sir!!! Amazing Work!!!!

harihardhik
Автор

you are the best.I really appreciate your hard work and step-by-step approach to how to overcome with a solution. Hats off

pooja
Автор

you r really an excellent teacher one thing i want to tell ur explanation is better that striver thanks for providing such videos

aman_rockstar
Автор

Please keep uploading DSA/leetcode videos, they all are really helpful, thanks!

shacks-bb
Автор

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.

jst
Автор

Only just got into coding a few days ago coming from a teacher background. Great explanations!

joshuajacobs
Автор

Thank you for taking the time to create this video and make a clear explanation

elizabeth
Автор

Thanks a lot, I was able to understand this problem thanks to your efforts.

sarthakgadge
Автор

I was searching for the solution but do not found dryryn but u did it thank bro ❤️

brahmithegod
welcome to shbcf.ru