2 Sum Problem | 2 types of the same problem for Interviews | Brute-Better-Optimal

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

Problem links.

We have solved the problem, and we have gone from brute force and ended with the most optimal solution.

You can follow me across social media, all my handles are below:

0:00 Introduction of course
Рекомендации по теме
Комментарии
Автор

Let's march ahead, and create an unmatchable DSA course! ❤

Timestamps pleaseeee

Use the problem links in the description.

takeUforward
Автор

Striver, I cracked my coding interview by providing your optimal solution. Can’t thank you enough. You have changed lives of many. Keep doing great work ❤

TheITEngineer
Автор

Bro, I am a guy from Africa you are the first person in this tech community that inspires me that I can do it..
Hats off for you bro 🔥🔥🔥

habeeblaimusa
Автор

I can’t thank enough because you teach so well about the concepts of DSA compared to others. None of the paid resources out there have good content. All I can say is May God bless you with long life and happiness. You are making all of us to land in our dream job.

pragmaticcoder
Автор

00:06 The video covers the 'two sum problem' and its two varieties.

02:04 Two sum problem can be solved using brute force method

04:05 Optimizing 2 Sum problem using a better solution

06:08 Using hashing to easily retrieve elements from a data structure.

08:13 Find the indexes of two elements in an array

10:30 Two pointer approach is a slightly better solution to solve the problem without using a map data structure.

12:38 Using the two-sum problem to find pairs that add up to a given target

14:51 The time complexity of the algorithm is O(n)

16:49 Space complexity and array manipulation explanation

ankurjaiswal
Автор

bhaiya you're so much doing for us, even you live alone in Poland, you sacrifice your time for you and I understand every thing you teach as you are so good in explaining and making people understand. once again thanks a lot for this

many
Автор

We need more problem solving videos. Explanation is super. I have gone through a few channels but this is the best! Thank you so much.❤️

suravighosal
Автор

Man after watching the first 5 videos and solving the problems on my own, I was also able to solve almost all medium and some hard problems. Watching these videos really built my logic, these lectures are a gold mine.

Josuke
Автор

This is the consistency we need from you bhai! 🔥

harshavardhan
Автор

Man you have changed a lot, this new version feels like a super saiyan mode.

aryansinha
Автор

GREAT BHAIYA I buy multiple dsa courses but i only understand with ur lectures
🤗🤗

secretcoder
Автор

Understood! Thanks a billion for your top-notch explaination brother!

itzmartin
Автор

When he introduced two pointer method my mind was like 🤯💥 Thank you striver!!!

parthkolgiri
Автор

Done this video. Amazing explanation. Learning amazing. Growing amazingly.

md.ualiurrahmanrahat
Автор

Raj, Thanks a lot for This Amazing Video about C++ Arrays
Video - 5 Completed ✅

PrithaMajumder
Автор

int main() {int n=3;
int array[3]={3, 2, 4}; int target=6;
for(int i=0; i<n-1;i++){
for(int j=i+1; j<n; j++){

cout<< i<<j;
break;
}
}
}
}

yashwanthostwal
Автор

🎯 Key Takeaways for quick navigation:

00:45 📚 *The video is part of the Striver's A to Z DSA course, covering comprehensive content with a guarantee of deep understanding in DS algo for interviews worldwide.*
01:12 🎯 *The Two Sum problem has two varieties: one asks for a yes or no if a pair with the given sum exists, and the other requires returning the indices of the pair.*
02:50 🧠 *The initial Brute Force solution involves nested loops to check every pair's sum.*
05:24 ⏩ *The improved solution uses hashing, mapping array elements to their indices, reducing time complexity to O(n).*
09:17 🚀 *The optimal approach, sorting the array and using two pointers, achieves O(n log n) time complexity without extra space.*
15:16 🔄 *The space complexity for the two-pointer approach is O(1), considering no additional space is used.*
17:50 📂 *Code for all three approaches (Brute Force, Hashing, Two-Pointer) is available in C++, Java, and Python in the video description.*

Made with HARPA AI

harshitrautela
Автор

When I was asked before. I first sorted the array and done the binary search instead of hashmap to find the target. Wish i saw ur video then.

alwinz
Автор

Understood ! This is the first ques of my challenge 😃

KomalSingh-qrmu
Автор

goddamn, maybe it was the first time, I understood the approach from the video and coded it on my own and got it accepted. God complex bruhh

tanmaykarn