Two Sum (LeetCode #1) | 3 Solutions with animations | Study Algorithms
Nikhil Lohia Nikhil Lohia
49K subscribers
72,090 views
1.7K

 Published On Feb 5, 2021

To see more videos like this, you can buy me a coffee: https://www.buymeacoffee.com/studyalg...

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:
Brute Force Method:    • Brute Force algorithms with real life...  
Quick Sort:    • Quick Sort super easy explanation wit...  
Time Complexity:    • What is the Time Complexity of an Alg...  

Actual problem on LeetCode: https://leetcode.com/problems/two-sum/
Code on Github: https://github.com/nikoo28/java-solut...
Test cases on GitHub: https://github.com/nikoo28/java-solut...

📘 A text based explanation is available at: https://studyalgorithms.com/array/lee...

🔗 To see more videos like this, you can show your support on: https://www.buymeacoffee.com/studyalg...

💻 Get Social 💻
Follow on Facebook at:   / studyalgos  
Follow on Twitter at:   / studyalgorithms  
Follow on Tumblr at:   / studyalgos  
Subscribe to RSS feeds: https://studyalgorithms.com/feed/
Join fan mail: http://eepurl.com/g9Dadv

#leetcode #programming #interview

show more

Share/Embed