Lecture 10: Solving LeetCode/CodeStudio Questions [Arrays]

preview_player
Показать описание
In this Video, we are going to solve LeetCode /CodeStudioProblems:

There is a lot to learn, Keep in mind “ Mnn boot karega k chor yrr apne se nahi yoga ya maza nahi para, Just ask 1 question “ Why I started ? “

Homework: Added in Video already
Howework question:

Telegram Group Link: Love Babbar CODE HELP

Do provide you feedback in the comments, we are going to make it best collectively.

Connect with me here:

Intro Sequence: We have bought all the required Licenses of the Audio, Video & Animation used.

Timestamps:

00:00 - Introduction
01:28 - Ques1 - Swap Alternates
02:49 - Promotion
03:53 - Example
07:03 - Implementation
10:58 - Dry Run again
13:23 - Swap Function breakdown
16:43 - Ques2 - Find Unique element
25:03 - Implementation
26:55 - LeetCode Homework
30:46 - Ques3 - Find Duplicates
36:21 - Implementation
38:38 - Homework
40:51 - Ques4 - Array Intersection
46:22 - Implementation
50:51 - Got TLE
51:18 - Optimisation 1
54:40 - Optimisation 2
01:01:28 - Ques5 - Pair Sum
01:03:43 - Implementation
01:10:06 - Dry Run
01:11:27 - Ques6 - Find triplets with given sum
01:14:53 - Ques7 - Sort 0 1
01:21:20 - implementation
01:33:23 - Homework

#DSABusted #LoveBabbar
Рекомендации по теме
Комментарии
Автор

First I have completed all DSA series and now conclude this is Greatest ever DSA series to exist on youtube or paid courses. Your contribution will be remembered. You're God of DSA for us🙇‍♂

govindsuryavanshi
Автор

I don't usually do comments.. but for this playlist.. I couldn't stop myself.. the best playlist I can found is your... I tried multiple playlist for learning c++ and dsa but couldn't find the one who can teach as good as you do.. thank you so much bhaiya..

komalnagori
Автор

00:00 - Introduction
01:28 - Ques1 - Swap Alternates
02:49 - Promotion
03:53 - Example
07:03 - Implementation
10:58 - Dry Run again
13:23 - Swap Function breakdown
16:43 - Ques2 - Find Unique element
25:03 - Implementation
26:55 - LeetCode Homework
30:46 - Ques3 - Find Duplicates
36:21 - Implementation
38:38 - Homework
40:51 - Ques4 - Array Intersection
46:22 - Implementation
50:51 - Got TLE
51:18 - Optimisation 1
54:40 - Optimisation 2
01:01:28 - Ques5 - Pair Sum
01:03:43 - Implementation
01:10:06 - Dry Run
01:11:27 - Ques6 - Find triplets with given sum
01:14:53 - Ques7 - Sort 0 1
01:21:20 - implementation
01:33:23 - Homework

narutodihargo
Автор

This video lecture series is seriously helping me to recollect my lost grounds once again. Can't thank you enough Love for these outstanding lectures. 🥺

RandomIndianStuff
Автор

For swapping adjacent element I initialized i with 1. it help to remove if condition.
for(int i = 1; i < size; i = i+2){
swap(arr[i], arr[i-1]);
}

kunalprakash
Автор

If we get such teachers and such good explanation then no power in the world will stop me from going to product based company.
Love u babbar sir and Thank u so so much.

preetkatiyar
Автор

26:18 (Brute force approach ):
int findUnique(int *arr, int size)
{
//Write your code here
for(int i = 0; i < size; i++) {
int count = 0;
for(int j = 0; j < size; j++) {
if(arr[i] == arr[j]) {
count++;
}
}
if(count == 1) {
return arr[i];
}
}
return -1;
}

ritomukherjee
Автор

I am working professional in one of the MNC and following your DSA course. You are providing good content with depth explanation. Keep doing great work. Thanks

maheshsharma
Автор

31:00 homework--> duplicates in an array


int findDuplicate(vector<int> &arr)
{
int m[arr.size()]={};
for(int i=0; i<arr.size(); i++)
{
m[arr[i]]+=1;
if(m[arr[i]]>1) return arr[i];
}

}

O(n)--> time complexity
O(n)--> space complexity

robinofautumn
Автор

a better approach to solve at 38:10 is

// Write your code here
int N=arr.size();
int sum=0;
for(int i=0;i<arr.size();i++){
sum+=arr[i];
}
int ans=sum-((N*(N-1))/2);
return ans;

manishbulchandani
Автор

जो कठिनाईयों से सीखता है,
वही आसानी से समझा सकता है ।

जय श्री कृष्ण ❤🙇‍♂️🙏

amankumbhalwar
Автор

You're killing it🌟🌟
Keep posting till the end of the series.

rameshwari
Автор

1:33:57 (3 pointer solution with O(n) Time complexity ):
#include <bits/stdc++.h>
void sort012(int *arr, int n)
{
// Write your code here
int i = 0;
int mid = 0;
int k = n - 1;

while ( mid <= k ) {
if(arr[mid] == 0) {
swap(arr[i], arr[mid]);
i++;
mid++;
}
else if(arr[mid] == 1) {
mid++;
}
else if(arr[mid] == 2) {
swap(arr[mid], arr[k]);
k--;
}
}
}

ritomukherjee
Автор

Swap alternate

start=0;
end=1;
While(end<n-1) {
Swap kro start or end index :
start=start+2;
end=end+2;
}

Op-fire-qqxl
Автор

39:25 we can also do this question by adding all numbers from 1 to N-1 and then subtracting it with sum of array, it will give us the repeating number

aryanisgood
Автор

duplicte element:-
int findDuplicate(vector<int> &arr)
{
// Write your code here
int n=arr.size();
int sum1=0;
int sum2=0;
for(int i=0;i<n;i++)
{
sum1=sum1+arr[i];
}
for(int i=1;i<=n-1;i++)
{
sum2=sum2+i;
}
return sum1-sum2;
}

vitragrathi
Автор

01:14:53 - Ques7 - Sort 0 1
🔸void sort_01(int arr[], int n) {
int i = 0, j = n - 1;
while(i<j){
//arr[i] is on desired position
if (arr[i]==0){
i++;
}
//arr[j] is on desired position
else if(arr[j]==1){
j--;
}
// if arr[i]==1 and arr[j]==0, both are on wrong position, so we just need to swap
else{
swap(arr[i], arr[j]);
i++;
j--;
}
}
}

ritikagrover
Автор

23:10 How the xor operator works? Specially with integers
26:55
39:38 How to do it?
1:33:33

soham_mondal
Автор

to swap alternate elements in an array
we can use a single loop for both even and odd sized arrays
i thought this logic and it works very well

for(int j=0; j<size-1; j+=2){
int a=array[ j ] ;
array[ j ] = array[ j +1 ] ;
array [ j + 1] = a ;
}
that's it

_Itachiii
Автор

Bro, thanks for the video!!
It's great that you haven't deleted/cut the video parts where you have made mistakes in the logic. Due to this we are also learning "how to debug our code". It's really helpful man!

Thanks a lot Love!!

Master-sysi