love you bhaiya chije tough he par laga rahunga aur acche se mehnat karunga aur seekhunga aap se pata ni kyo ek relatability vali feeling aati he thanks for the course love you
ye search in rotated array ke question mai bahut din se fasa hua tha. paid course wale ka samaz hi nahi aa raha tha. lekin jab aapke video se dekha to pura logic clear ho gaya. thank you for making dsa easy
17:52 We can also write the statement in this way. mid = end - (end-start)/2; which looks more similar and easy to remember as mid = start + (end-start)/2
why mid=start+(end-start)/2 giving error and mid=end+(start-end)/2 not giving error?In both case mid evaluates to zero and also in both cases ig there is no overflow according to condition given in question..
@@AbhishekKumar-ks1fd if we use mid=start+(end-start)/2 then it will move to 0th index if the required element is present at index 1 .and if we use mid=end+(start-end)/2 then it will move to 1st index for which we can compare the previous element arr[mid-1] which is not the case if we use mid=end+(start-end)/2 .for better understanding dry run this case [1,9,5,3,2].
Ram Ram rohit bhai abh kaafi bddiya samajh aa raha hai leetcode ke problems bhi solve kar paa raha hoon all thanx to your great effort to make us fall in love with DSA sab chamk raha hai ✅
Hope you are doing well sir . I really appreciate your hard work . Your explaination of each question is so good and it help me to understand the problem as well solution . Thankyou for making this aswome playlist for us.
My intuition behind ans + K : ✅✅ We found that in the array before ans index, there are total ans elements present currently. And we know there are at least K elements missing It means that, before that ans index there should be total at least (ans + k) elements . Let's take example of the question: [2,3,4,7,11,12] , we found that before index 4th, there are total 4 elements. Now, we also know that there are at least 5 elements missing before 4th index. so at least total elements before index 4th = 4 elements + at least 5 missing elements = at least 9 elements. And we know that 9th element is basically 9 (which is missing) (NOTE: In this case total 6 elements missing before index 4, so total elements before 4 would be = 4 + 6 = 10), so 9th element is 9, 10th is 10)
hello bhaiya. Thank you for your efforts. {17:25 bhaiya agar hum es code ka use kare tho hume mid value m koi change kare ki jarurat nhai padegi. } int s=0,e=arr.size()-1; int mid ; while(sarr[mid-1]){ s=mid+1; } else{ e=mid; } } return -1;
17:44 reason simple hai. If you are using comparision for arr-> mid with arr->mid-1. use mid = end + (start - end ) /2 If you are using comparision for arr-> mid with arr->mid+1. use mid = start + (end - start) /2 it depends on your way of writing code. ******* Now for the dry run part on : arr [1,6,3,2,1]. sir Used mid = start + (end - start) /2, but used the mid-1 for comparision, so for Start = 0, and end = 1. mid = 0, now if we try to compare mid with mid -1 , which was accessing the index -1. we got error.
abb mental pressure badh raha h question ki difficulty aur variation k sath kal ki claas ke quesions ko khud se debug krne m 3 ghnte extra lage taki cheeje mentally accept ho jaye 🥲
Yeh saare bohot hi simple questions hai, agar yeh bhi tumhe difficult lagg rahe hai toh tumhara basics clear nahi hai, ek baar binary search doobara se padho, different cheeze try karo code me like returning s or e in the end, etc. Ek baar binary search samajh gaye toh yeh questions bohot easy lagengi.
Q peak element class Solution { public: int peakIndexInMountainArray(vector& arr) { int n=arr.size(); int start=0,end=n-1, mid=-1,index=-1; while(startarr[mid+1]){ index=mid; end=mid-1;
@Rohit bhai aap hume chamkaane mai mahnat pe lage ho humm market mai chamka denge. 🎉❤ ekdam dhaanshu ja raha h jise bolte hai dhaanshu. Bhai aapne sabb pay after placement bootcamp ke laga di hai achhe se 😂😂😂 aur jitne bhi high price unaffirdable inatituions ke laga di 😂😂😂😅😅😅😅❤❤❤. Rohit bhai coder-army family ki taraf se dil se saalam🙌🙏
1:00:01 i am confuse in the else if condition ,in the previous example the value of [arr[mid] >= arr[0] ] this condition was not true so how can this code further proceed ?
okay so I've watched this one lecture for like 3-4 hours now and ab jake it has been finished now the important thing is ki aaj ke lec ka ek bhi ques khud se nahi hua; but still after you giving a simple kickstart dimaag daudne laga bhaiya thankyou for the lecture; _/\_
int peakIndexInMountainArray(vector& arr) { int start=0,end=arr.size()-1,mid,ans=-1; while(startarr[mid-1] && arr[mid]>arr[mid+1]) { ans = mid; break; } else if(arr[mid+1]>arr[mid]) { start = mid ; } else{ end = mid ; } } return ans; I have solved this question by my self thanks Bhai ❤
okay so i think i know the reason why for Q1 aapke wale mid ne error nai mara i think the main reason is that usme 0 ban hi nahi sakta is particular case mein that is 1-1/2=1 as int variable tha SERIOUSLY BEAUTIFUL!!!!!!\
@@CoderArmy9 bhaiya I'm to still join a college and abhi se I've started this playlist but trust me all of your ways to explaining things have just blown away my mind I knew NOTHING about coding whatsoever but from te past 3.5 weeks ive done yaha tak with hw and the process is just FIRE WITH ALL DUE RESPECT AND LOVE, THANKS A LOT BHAIYA !!WILL CONTINUE THIS INTENSITY!!
Bhaiya dout support ka kya hua!?? Mene multiple times aa same chiz comment bhi ki different videos pe pr koi reply nhi aata. Mene subscription liya hua hai pr jo links aape provide kiya he bo khulte nhi or aap new link provide krbate nhi mene aase a aspect nhi kiya tha!
Hello Coder, Sab chamak rha hai?
Hanji bhaiya
Hanji bhaiya.
mast bhaiya ab maja aa raha h. thank u bhaiya🙏🙏
Akdam bhaiya ❤❤
yeah
love you bhaiya chije tough he par laga rahunga aur acche se mehnat karunga aur seekhunga aap se pata ni kyo ek relatability vali feeling aati he thanks for the course
love you
ye search in rotated array ke question mai bahut din se fasa hua tha. paid course wale ka samaz hi nahi aa raha tha. lekin jab aapke video se dekha to pura logic clear ho gaya.
thank you for making dsa easy
Simple brutforce approch:
for(int i=0;i
leetcode ke 2nd test case prr fail ho jyga
what is n here?
@@collegelife7800 yeh vala try kro, fail nhi hoga,
class Solution {
public:
int findKthPositive(vector& arr, int k)
{
int i = 0, num = 0;
while(k != 0)
{
num++;
if(i < arr.size() && arr[i] == num)
{
i++;
}
else //arr[i] != num
{
k--;
}
}
return num;
}
};
Best explanation for search in sorted roated array easiest approach till I seen
Superb bhaiya the way you are teaching is so unique
17:52 We can also write the statement in this way.
mid = end - (end-start)/2; which looks more similar and easy to remember as
mid = start + (end-start)/2
why mid=start+(end-start)/2 giving error and mid=end+(start-end)/2 not giving error?In both case mid evaluates to zero and also in both cases ig there is no overflow according to condition given in question..
@@AbhishekKumar-ks1fd if we use mid=start+(end-start)/2 then it will move to 0th index if the required element is present at index 1 .and if we use mid=end+(start-end)/2 then it will move to 1st index for which we can compare the previous element arr[mid-1] which is not the case if we use mid=end+(start-end)/2 .for better understanding
dry run this case [1,9,5,3,2].
@@adeebahmed1891 how will I get to know where to use mid=start+(end-start)/2 and where to use mid=end+(end-start)/2;
@@therealsumitshah it is a better approach. We generally use end+(start-end) /2 . We can use it everywhere.
Literally you are a great teacher , so called overrated teachers can't teach like you brother ! ❤️
Ram Ram rohit bhai abh kaafi bddiya samajh aa raha hai leetcode ke problems bhi solve kar paa raha hoon all thanx to your great effort to make us fall in love with DSA sab chamk raha hai ✅
Hope you are doing well sir . I really appreciate your hard work . Your explaination of each question is so good and it help me to understand the problem as well solution . Thankyou for making this aswome playlist for us.
My intuition behind ans + K : ✅✅
We found that in the array before ans index, there are total ans elements present currently.
And we know there are at least K elements missing
It means that, before that ans index there should be total at least (ans + k) elements .
Let's take example of the question:
[2,3,4,7,11,12] , we found that before index 4th, there are total 4 elements.
Now, we also know that there are at least 5 elements missing before 4th index.
so at least total elements before index 4th = 4 elements + at least 5 missing elements = at least 9 elements.
And we know that 9th element is basically 9 (which is missing)
(NOTE: In this case total 6 elements missing before index 4, so total elements before 4 would be = 4 + 6 = 10), so 9th element is 9, 10th is 10)
00:01 Find Minimum in Rotated
18:05 Peak Index
1:04:55 Kth Missing
August 5 : Revision Day 5
Questions on binary search done ✅✅✅
(BTW Last question is still little bit tough 😅😅)
hello bhaiya. Thank you for your efforts.
{17:25 bhaiya agar hum es code ka use kare tho hume mid value m koi change kare ki jarurat nhai padegi. }
int s=0,e=arr.size()-1;
int mid ;
while(sarr[mid-1]){
s=mid+1;
} else{
e=mid;
}
}
return -1;
Bhai bhaiya ke rotated array mein dikkat aa rhi hn answer galat aa rhe hn
Bahut tagda lecture tha bhaiya...❤💯🚀
Finally I found the best explanation for search in sorted array
Day 32 done and dusted..... Crytal clear everything. Best Bhaiya.... consistency
We are getting motivated by seeing your effort bhaiya..
ajka class thora hardd tha but dry run karta karta samaj aa gya bhaiya thanks ..
Haan Bhai....Kth missing wala smj aaya ?
19:05
class Solution {
public:
int findMin(vector& nums) {
if(nums[0]
17:44 reason simple hai.
If you are using comparision for arr-> mid with arr->mid-1.
use mid = end + (start - end ) /2
If you are using comparision for arr-> mid with arr->mid+1.
use mid = start + (end - start) /2
it depends on your way of writing code.
******* Now for the dry run part on : arr [1,6,3,2,1].
sir Used mid = start + (end - start) /2,
but used the mid-1 for comparision,
so for Start = 0, and end = 1.
mid = 0, now if we try to compare mid with mid -1 , which was accessing the index -1. we got error.
But for example , 2 3 5 4 1 0 , if we write the else if condition as arr[mid] >arr[mid+1] , then end = mid -1 ....then we get error . please check
@@shrutigawade8747it will not reach else ifpart
it will return mid as peak value i think🤔as first condition will get true..
Really very nice explanation.
thanks for this type of amazing lectures.
Bhaiya agar code share kar dete to bohot accha hota, thanks for your valuable content, love you
Chamka par yeh vapis dekhna hoga best explanation k liye 👍🏻
bhaiya DSA krne ka mn ni krta tha but apki videos dhk kr mzza aa rha hai or DSA b solve ho rha hai
chalu late kiya par maza aara hai bhaiyaaaaaaaaaaa
kis year me hai bhai?
bhaiya video banana band mat karna bhut se log bhich me hi chod dete he aap please pura course complete kijiyega
thankyou
🏃♀Day 9✅
tysm bhaiya
32/180 done thanku bhaiya🙃
Congratulations for 30k family members Rohit bhaai and CoderArmy family members 🎉
1:35
class Solution {
public:
int peakIndexInMountainArray(vector& arr) {
int start = 0,end = arr.size()-1,mid;
while(startarr[mid-1] && arr[mid] > arr[mid+1])
return mid;
else if(mid!=arr.size()-1 && arr[mid+1]>arr[mid])
start = mid+1;
else
end = mid-1;
}
return start;
}
};
Funny part of video is that kth missing wala code easy category me hai (waah re leetcode) 😂 1:30:24
😂😂😂😂sahi kha use smjhne mai medium questions se jyada smay lga 😭
@@VivekSingh-hn4xr real 🥲
@@VivekSingh-hn4xrbhai dimag kharab ho gaya
0:0 q1 ,13:26 it's code,18:06 q2 39:35 it's code ,42:45 q3 1:00:34 it's code,1:04:54 q4 1:24:16 it's code and questions description se dekh lena
Thankyou
abb mental pressure badh raha h question ki difficulty aur variation k sath kal ki claas ke quesions ko khud se debug krne m 3 ghnte extra lage taki cheeje mentally accept ho jaye 🥲
Same bhai😢
Yeh saare bohot hi simple questions hai, agar yeh bhi tumhe difficult lagg rahe hai toh tumhara basics clear nahi hai, ek baar binary search doobara se padho, different cheeze try karo code me like returning s or e in the end, etc.
Ek baar binary search samajh gaye toh yeh questions bohot easy lagengi.
@@tusharagarwal5306 i agree ye easy hai par ye approach ko aane ke liye practice lagega
@tusharagarwal5306 bro easy hoo ya difficult easy bolke agge niklo ge too mushkil hai question samj ne ki baad bhi ek baar khud se dryrun karo
apne to DSA me aag laga diya , mast he
hi rohit bro this videos is really help full for me thanks for this series
class Solution:
def findKthPositive(self, arr: List[int], k: int) -> int:
start = 0
end = len(arr) - 1
while end >= start:
mid = start + (end - start) // 2
if arr[mid] - 1 - mid < k:
start = mid + 1
else:
end = mid - 1
return start + k
bhaiyaaa bht zada ache se smjh aa ra hai thank you
bahut bhadiya bhaiya 😀😀😀😀
Your understanding find is very best
Love you sir ❤❤
Day 24 Completed ✅❤🎉
At 17:45 if array is 1 2 3 6 1 mid =4+(3-4)/2=4 for(6,1) then for last 1 we have to check for right but this time it should also give us error...so??
mazaa aa gaya bhaiya iss lecture se ekdam se babu wali feel ho gayi😂😂😂😂
Done Bhaiya... Day 32/180 ✅
Thank you so much sir🥰
Badhiya rha ye session #Chamka
37:00
1:03:24 third problem
Thank you bhaiya.
Baap of all dsa teacher rohit negi❤
Day 32/180 completed
sir is like a magician
Done Bhaiya... 32/180 ✅
Watching from NIT Srinagar
ok watching from MIT
Please like and share this series with your friends whose not offered paid course ❤
Q peak element
class Solution {
public:
int peakIndexInMountainArray(vector& arr) {
int n=arr.size();
int start=0,end=n-1, mid=-1,index=-1;
while(startarr[mid+1]){
index=mid;
end=mid-1;
}
else{
start=mid+1;
}
}
return index;
}
};
@Rohit bhai aap hume chamkaane mai mahnat pe lage ho humm market mai chamka denge. 🎉❤ ekdam dhaanshu ja raha h jise bolte hai dhaanshu. Bhai aapne sabb pay after placement bootcamp ke laga di hai achhe se 😂😂😂 aur jitne bhi high price unaffirdable inatituions ke laga di 😂😂😂😅😅😅😅❤❤❤. Rohit bhai coder-army family ki taraf se dil se saalam🙌🙏
Thankyou for 24 😊
doubt
when to use ;- while(start
It's dépend on condition
Both are same bro.
No íts not same it's dépend on condition of start ànd end
Okh.
always use while(start
Amazing explanation bro ❤❤
Good morning 🌞🌞
every part is amaging====++
Day 32 👍✅ Chamak Gaya
Thank you Bhai ❤
1:04:54 kth missing positive number
search in rotated array confusing bhiyya.but the lecture and efforts of you is good
1:00:01 i am confuse in the else if condition ,in the previous example the value of [arr[mid] >= arr[0] ] this condition was not true so how can this code further proceed ?
32/180 Day's full power full power ❤❤❤❤
okay so I've watched this one lecture for like 3-4 hours now and ab jake it has been finished
now the important thing is ki aaj ke lec ka ek bhi ques khud se nahi hua;
but still after you giving a simple kickstart dimaag daudne laga bhaiya
thankyou for the lecture; _/\_
It's comletely fine bhai, focus on making notes and do revision
@@CoderArmy9 already done bhaiya!!
@@CoderArmy9almost 9 hours lagge sabhi questions samj aagaye even samja ne ke phele kuch questions samj aagaye par last vala bhot hard tha
Good morning boss ❤
Good morning bhaiya ❤️❤️
Best teacher
ohhh bhaisaaab
Day 32 done ✅✅✅❤❤❤
Good morning 🌞
Thanks for motivating bhai❤
17:52 ka samaj nahi aaya
Whats the difference between start + (end-start)/2 and end +(start-end)/2 while calculating mid
Int overloading
@@Programmer_sumit thanks
Day-32🔥 Completed
#180daysofcode
Covering backlogs
Mast bhaiya.
40:10 and if array assigned discriminate orders then ?
thank you brother
Good morning Bhaiya❤
Good morning negi bhai❤️
bhaiya revision done
Bhaiya will you cover dsa from basic to advance on RUclips
Good morning bhaiya..❤️
Good morning ❤❤
int peakIndexInMountainArray(vector& arr) {
int start=0,end=arr.size()-1,mid,ans=-1;
while(startarr[mid-1] && arr[mid]>arr[mid+1])
{
ans = mid;
break;
}
else if(arr[mid+1]>arr[mid])
{
start = mid ;
}
else{
end = mid ;
}
}
return ans;
I have solved this question by my self thanks Bhai ❤
Code samj too agaya par yad hi rakhna padega yiska logic bana bhot mushkil hai
Bhaiya DP k liye bhi series chahiye
Bhaiya ek confusion h agar arrays ko sorted bolte h to it means ki arrays must be in increasing order 🤔🤔.
Nahi bhai, wo question mein given rhega sorted ka meaning, wo increasing ki baat kar rha hai ya decreasing ka
Thanks Bhaiya...❤🎉
32 days completed ✅
Day 32/180, #180daysofcode #180 hard
okay so i think i know the reason why for Q1 aapke wale mid ne error nai mara
i think the main reason is that usme 0 ban hi nahi sakta is particular case mein that is 1-1/2=1 as int variable tha
SERIOUSLY BEAUTIFUL!!!!!!\
Good job my friend ❤️
@@CoderArmy9 bhaiya I'm to still join a college and abhi se I've started this playlist but trust me all of your ways to explaining things have just blown away my mind
I knew NOTHING about coding whatsoever but from te past 3.5 weeks ive done yaha tak with hw and the process is just FIRE
WITH ALL DUE RESPECT AND LOVE, THANKS A LOT BHAIYA !!WILL CONTINUE THIS INTENSITY!!
bhaiya i got error in kth missing element for arr=[2] and k=1
#32 out of 180
peak index in mountain
class Solution {
public:
int find_pivot(vectorv){
int s=0, e=v.size()-1;
int mid = (s+e)/2;
while(s
this logic of rotated array for finding min. value is not working in {8,7,2,4} why ?
Pta chala bhai kyo nhi run ho rha please tell
day 32 done!!
Bhaiya last wala kth missing number thoda samajh nhi aaya
Bhaiya dout support ka kya hua!??
Mene multiple times aa same chiz comment bhi ki different videos pe pr koi reply nhi aata.
Mene subscription liya hua hai pr jo links aape provide kiya he bo khulte nhi or aap new link provide krbate nhi mene aase a aspect nhi kiya tha!