Lecture14: Binary Search Interview Questions [Google, Amazon, Microsoft] || ProblemSet - 2

preview_player
Показать описание
In this Video, we are going to solve LeetCode questions using the concept of Binary Search.

Questions Solved:
- Find Pivot in an Sorted & Rotated Array using Binary Search
- Search an Element in a Sorted & Rotated array using Binary Search
- Find Square Root of an Integer[both int & floating part] using Binary Search

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

Question Links:
- Find Pivot in an array:

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

Telegram Group Link: Love Babbar CODE HELP

Connect with me here:

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

Timestamps:

00:00 - Introduction
01:33 - Find Pivot in an array
11:19 - Implementation
16:58 - Search in a Rotated and Sorted Array
23:39 Implementation
28:41 - Square Root using binary Search
38:51 - Implementation
43:15 - Finding the float part in Square Root
45:29 - Implementation
51:29 - Dry Run

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

This is the best dsa series on

My request is to everyone who is reading this comment plz share this playlist with your juniors and friends. You can share with at least one friend.

ketangaikwad
Автор

pivot you explain is other and array is sorted but in previous lecture you told us to solve a leetcode question 724 in which pivot means this-:
The pivot index is the index where the sum of all the numbers strictly to the left of the index is equal to the sum of all the numbers strictly to the index's right.

ishangrover
Автор

Bhaiyya aap OP ho pivot wala problem teen baar dekhne ke baad samjh aaya uske baaad toh chize easy kardiye aapne.Thanks bhaiyya having a teacher like you can get me a job in Google.❤❤❤

AbdulWahab-jlun
Автор

the approach of finding the piovt element is correct and in most o fthe cases it will retrun the correct value, but in inputs like {11, 13, 15, 17}, the pivot will move to index 3 but it is wrong, so aas per me logic we should declare a temp variable outside the loop value 0. after the loop is terminated we will compare the value of temp index with the start index value if the value of the start index is smaller we will return start else we will return temp.. this will help to find the piovt in all cases, whether the array is rotated or not..

rahulra
Автор

Another approach to find pivot in an array !!!

int getpivot(int arr[], int n){
int s = 0;
int e = n-1;

int mid = s + (e-s)/2;

while(s<e){
if(arr[mid]<arr[n-1]){
e = mid;
}

else if(arr[mid]>arr[n-1]){
s = mid + 1;
}

mid = s + (e-s)/2;
}
return s;
}

Nice Lecture Bhaiya 😊 !!

zhrrBro
Автор

Thank you so much bhaiya.. ye series bahut achchi hai jab maine dsa start kiya tha to normal sa question banane mai bhi ghanto lag jate the but abhi apki vajah se aaj maine 3 achche questions 40 min mai kar liye.. thank you so much... ab confidence bhi aa rha hai ki ho jayega dsa

harshitaverma
Автор

Staying strong with you...14th lecture!
No going back Babbar bro...
I love the series till now.
Especially the optimized way to find mid-value and also these binary search questions are making me think better. I'll comment in the next video. See you then!

Regards,
Dharrsan

dharrsanamarnath
Автор

49:37
"mujhe lag rha hai ki aapko bilkul smjh nhi aa rha",
"mujhe pata hai aapko nhi aa rha "
"tension na le, "
"mujhe pata lg gya aapko smjh nhi aa rha "
VERY VERY ACURATE FOR ME AT THIS MOMENT
mai shock ho gya laga aamne saamne padh rha

amandwivedi
Автор

You deserves millions of subscribers for your hardwork bro. You are way better than code with Harry telusku etc etc. You explains everything twice no one even do it once properly. Hats off to you sir. Keep growing.❤️

lovishmittal
Автор

It has been the best series so far on youtube. This series is really helping me to improve my thinking & logic building skills .
Thank you bhaiya...keep it up.

sudhanshusingh
Автор

We all are with you bhaiya. please be constant till the end. Your way of teaching is excellent.

puneet
Автор

Truly Great series sir, You have truly helped me overcome my fear of DSA.
Thank You very Much.

devanshusahoo
Автор

in pivot element, if the array is not rotated in edge case then it will return last index that is wrong so we have to compare with last element not first element in array,
int findMin(vector<int>& nums) {
int start = 0;
int end = nums.size()-1;
int mid = start+(end-start)/2;
while(start<end){

start = mid+1;
}else{
end = mid;
}
mid = start+(end-start)/2;
}
return start
}

raunakbaliyan
Автор

Sir two suggestion 1) First one is If possible you give topic time table that which topic you will teach in which day or date so all can atleast prepare the topic understand the topic by themselves and solve some problems related to topic which helps to understand all points that you taught in video 2) And second one is you give all difficulty level question links ( generally medium and hard) and maximum problems of that topic that all can master the topic and solve any problem of that topic in all formats in interview or in CP, or in leetcode and all other platforms....

Nishad_Ranade
Автор

2:30 The way you use colors of Indian flag and explain concepts is soo satisfying. You are contributing a lot to India indirectly by making a big change in Education industry.

bernardhackwell
Автор

31:40 Bhaiya At this timestamp of video, I would suggest try to start an array from [ 1 to n/2 ]. Reason is for any number n, square root of n is always smaller than n/2 ( Corollary Based on popular Theorem ).I don't remember the name of that theorem. This will slightly optimize an algorithm.

Example : n = 36 ==> 6 < 18
n = 81. ==> 9 < 40
n = 625 ==> 25 < 312 and so on ..

rockinhitzz
Автор

Difference of Love babbar and Aman dattarwal course is :-
Aman dattarwal course made by FAANG people's and love babbar course made to crack FAANG

bmohdzaid
Автор

This series is very helpful; thanks a lot ❤️

shubham_jha
Автор

if anyone finding 11:23 answer here it is
class Solution {
public:
int pivotIndex(vector<int>& nums) {
// accumulate is a stl which is used to addition of array
int rs=accumulate(nums.begin(), nums.end(), 0);
int ls=0;
for(int i=0;i<nums.size();i++){
rs-=nums[i];
if(ls==rs){
return i;
}
ls+=nums[i];
}
return -1;

}
};

primeop
Автор

Thank you so much bhaiya for bringing such a great, full fledged and premium content in free of cost for all of us
We are putting our effort 👌 💪 🙂 👏 🙌

shivamjha
join shbcf.ru