Two Pointer Technique | Competitive Programming

  Рет қаралды 33,702

Ashish Kumar

Ashish Kumar

Күн бұрын

Hey Guys, In this video I have explained two pointers technique which is helpful in Competitive Programming and coding interviews.
Algorithms Playlist: • Algorithms with Practi...
Placement Preparation Playlist: • Placement Preparation ...
Competitive Programming Playlist: • Competitive Programmin...
Graph Theory Playlist: • Graph Theory Complete
Subscribe for more competitive programming and DSA videos!

Пікірлер: 40
@ashishcode
@ashishcode 11 ай бұрын
Hi Guys, you can now book a 1:1 call with me on topmate.io/ashishcode for placement guidance and more at a very affordable price. Use code KZbin30 for 30% off! (Only for first 15 Users)
@bebo5619
@bebo5619 Жыл бұрын
Thank you very much, I am on a time crunch studying for the second round of a huge interview and your video made the concept very simple and understandable. You're amazing, keep doing what you are doing!
@GamingUnitesGR
@GamingUnitesGR Жыл бұрын
how did the interview go?
@Asli_Investing
@Asli_Investing 3 жыл бұрын
Nicely Explained :) Saved me some time by building the intuition quickly
@gouravm4986
@gouravm4986 4 жыл бұрын
Please make a playlist of these things.. Would be really helpful.. I solved two question myself after watching this video so kinda very helpful for me.. Also shared your video to my friends. 😊thank you sir
@ashishcode
@ashishcode 4 жыл бұрын
Thank you so much for your kind words.. I will be sure to continue!
@tentx652
@tentx652 3 жыл бұрын
hey bro ....the way u explain is simply awesome.Covering all the edge points is great ,ATB man!!
@hyperoid3901
@hyperoid3901 4 жыл бұрын
Thank you very much Ashish, well explained with your demonstration.
@sandeepaksingh9248
@sandeepaksingh9248 4 жыл бұрын
Very nice. Keep it up make a series of competitive programming.
@bhushanmendhe7904
@bhushanmendhe7904 2 жыл бұрын
Loved the way you explained! Please bring more such videos on more such frequently used algorithms :)
@ashishcode
@ashishcode 2 жыл бұрын
Thank youu, sure I will.
@JackCoderr
@JackCoderr Жыл бұрын
Thank you so much bhaiya...you are a great teacher ❤❤❤
@saurabhnikam
@saurabhnikam 4 жыл бұрын
Really helpful .....good explanation.
@nileshchauhan7117
@nileshchauhan7117 2 жыл бұрын
Thanku so uch ashihs plz mak this more and more
@saransappa603
@saransappa603 4 жыл бұрын
Nice explanation Asish Kumar.
@dowenrobinson1589
@dowenrobinson1589 3 жыл бұрын
Excellent explanation
@akshaysb526
@akshaysb526 2 жыл бұрын
great explanation
@shreelbansal3026
@shreelbansal3026 3 жыл бұрын
Nice!!
@PrashantSingh-pg9vq
@PrashantSingh-pg9vq 3 жыл бұрын
what would be your explaination for this case? [0,2,4,5] diff=1;
@A5IR
@A5IR 3 жыл бұрын
i had the same thought. for this case, (2 - 0) will be 2, which is greater than 1. so we would increment the left pointer and now both pointers are at the same index. so I think we need to check if (i == j) we increment j. the while loop keeps going while j is less than length of array.
@Noone-kl6sc
@Noone-kl6sc 3 жыл бұрын
bool findPair(int arr[], int size, int n){ sort(arr, arr+size); int i=0; int j=1; while(i
@midhileshmomidi2434
@midhileshmomidi2434 4 жыл бұрын
When the array is not sorted then we have to use hashmap??
@ashishcode
@ashishcode 4 жыл бұрын
You can either use a hasmap or sort the array and then use two pointers technique.
@selvaragavan_10
@selvaragavan_10 Жыл бұрын
will two difference works for this test case? [1,5,9,13,14] target = 1;
@manishsharma2211
@manishsharma2211 3 жыл бұрын
Good One, thanks
@rohitpol
@rohitpol 2 жыл бұрын
Nice explanation bro 😎
@omkarpasalkar47
@omkarpasalkar47 2 жыл бұрын
Thank u so much brother
@tusharpandey6584
@tusharpandey6584 4 жыл бұрын
very nice explanation thx :3
@rba1aji216
@rba1aji216 2 жыл бұрын
can i use this two pointer technique in unsorted array??
@ashishcode
@ashishcode 2 жыл бұрын
No, it works only on sorted arrays.
@fuehrercheem
@fuehrercheem 3 жыл бұрын
Couldn't get better
@udbhavvikramsingh3449
@udbhavvikramsingh3449 3 жыл бұрын
how it is O(nlogn) time complexity someone explain plz why not (n*n)
@ashishcode
@ashishcode 3 жыл бұрын
It's O(nlogn) because we use sorting and sorting takes nlogn and then we have used only one traversal meaning only one for loop which takes O(n) so it becomes totally O(nlogn)
@udbhavvikramsingh3449
@udbhavvikramsingh3449 3 жыл бұрын
@@ashishcode got it
@saibharath780
@saibharath780 4 жыл бұрын
In hash map tech you used it contains liner search so it might take more time know
@saibharath780
@saibharath780 4 жыл бұрын
Bro can you give reply I am right or wrong
@ashishcode
@ashishcode 4 жыл бұрын
No,using hashmap it takes O(n) that is linear time which is better than sorting and then using two pointers which takes O(nlogn). If it's already sorted it will take O(n) which is same for using hashmap but hashmap will give O(n) even if not sorted. Sorry for the late reply.
@RN-jo8zt
@RN-jo8zt 2 жыл бұрын
Thanks
@Python_DSA_Journey
@Python_DSA_Journey 4 жыл бұрын
please tell the same with hashing
@joelcruz2873
@joelcruz2873 3 жыл бұрын
With a Map, you could place the index and value of each array element inside the Map. Then for each element, you subtract it from the target and look for that difference inside of the map (which will be O(1)). In the worst case you'll have to do this O(N) times.
Top 5 Competitive Programming Online Courses
6:16
Ashish Kumar
Рет қаралды 21 М.
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 324 М.
小丑妹妹插队被妈妈教训!#小丑#路飞#家庭#搞笑
00:12
家庭搞笑日记
Рет қаралды 36 МЛН
Players vs Corner Flags 🤯
00:28
LE FOOT EN VIDÉO
Рет қаралды 38 МЛН
Шок. Никокадо Авокадо похудел на 110 кг
00:44
How to Use the Two Pointer Technique
10:56
Team AlgoDaily
Рет қаралды 102 М.
Two Pointer Approach - CP TacTics | Two Sum Problem | The Code Mate
15:45
How to Crack TCS CodeVita in 30 Days | TCS CodeVita 2024
5:29
Ashish Kumar
Рет қаралды 3,4 М.
Companies are not asking DSA Anymore? Roadmap to Placements
10:12
Ashish Kumar
Рет қаралды 3,3 М.
Sliding Window Technique | Google Coding Interview | Maximum Size SubArray Of Size K
16:06
JAVAAID - Coding Interview Preparation
Рет қаралды 65 М.
Two Pointer Algorithm | Two Sum Problem | Solve DS Problems in O(N) Time
19:18
JAVAAID - Coding Interview Preparation
Рет қаралды 116 М.
Apple October Event LEAKS - 7 NEW Devices are COMING!
10:20
Max Tech
Рет қаралды 168 М.
5 Simple Steps for Solving Any Recursive Problem
21:03
Reducible
Рет қаралды 1,2 МЛН