No wonder how demotivated I was when I saw that question and was looking for a good explanation since last 7 days (no, not even exaggerating). But, this man is love!!! Keep going @Striver :) You're our hope!!
I was struggling with Binary search on sorted array for a long time, Your key point "Eliminate one half" has cleared my confusion. Thank you so much Striver
The best explanation I have found for this problem. Alog is very simple now 1. Identity the sorted half. 2. Check if the target lies in the sorted half. Thats it you need to do this two things only.
Ig after solving like 15 BS problems, that's somewhat how all BS qs probably are. Divide search space into two halves Use some condition to eliminate either of the half from the search space
None can compete with this man....!!! Simply amazing 👏. Great Work Striver Bhaiyya #DSA ka baap. The best thing about you is that you are not paid and spreading knowledge to all the aspirants...
The one who are selling just their courses and making abundant money are getting more and more fame and heavily recognised today, but the person who truly creating impact is just not even known by everyone today, But anyway thank u so much striver bhaiya , for this great quality content , i wish you will be respected by every cs student of india one day !!
here after love babar lec - 14 for rotated sorted array he is using the concept of pivot element which is little messy but striver what a lovely lovely explanation in 1 go i understood and coded it myself
honestly I was very confused and demotivated after watching Rohit negi sir's explanation in paid course , i spent 2 hour to understand this problem but could not get it , after watching strivers explanation i get it only after single iteration. thanks a lot . now i am going to follow strivers AtoZ DSA
Notes for me☺ As we get our mid at any index checks arr[num]==target if it satisfies return here. After that Case 1> Array is left sorted(we check it by standing on mid), ==>Checks where our target lies in sorted(between low to mid ) or outside it by using if(arr[low]=target) if it lies inside this it indicates we need to collapse window by taking high to mid -1 otherwise low to mid+1 Case 2> Array is right sorted similarly we check for it and updates our low and high accordingly if we never get it we return -1 to it
Looked at neetcode video, then yours. His explanation was a bit confusing and had to do some examples to understand it. Yours almost made it a regular easy binary search
what i did was i found the starting point using similar approach of binary search then applied binary search from that point...but this approach is goated
Amazing video, very good explanations, took sometime to understand but went through it again and again to understand it completely. Thanks for making such quality content Striver Bhai
YOU Can understand very well and i see a many video but my concept is not clear but just i see that video which would be clearly the concept very easily
Your explanation was much better than neetcodeio, thanks for explaining in such a detail. I was really missing the point to identify sorted part. Can you please tell me what app you are using for pencil work.
thank you so much sir...respect for your amazing efforts...really no one teaches better than you... raj cum striver..i wish for your long life and happiness..
You have perform binary search in sorted array ( keeping ascending order ) in mind. Am I right? This will not work if array is sorted ( can be in ascending /descending ) order ( not known before hand ). Correct me if I am wrong.
other method to solve is first find pivot element and then apply binary search accordingly either on left or on right side based on checking target element with pivot element using assignment operator.
no in worst case scenario it wont be O(N), because once you find the pivot, you can either binary search on the left half or the right half, so you need 3 binary searches in total, one for finding the pivot, one for searching on the left half and one for searching on the right half@@anshulgupta2136
Please comment understood and give us a like if you got everything :)
Understood sir! This really cleared my doubt regarding the process the code performed in else part! Thank you sir!!
Very well Understood sir 😀
Understood
Now I clearly know how you got a job at Google.😁
Understood
God tier explanation. I truly can't put in words how easily and clearly you were able to explain a seemingly confusing question!
No wonder how demotivated I was when I saw that question and was looking for a good explanation since last 7 days (no, not even exaggerating). But, this man is love!!! Keep going @Striver :) You're our hope!!
I was struggling with Binary search on sorted array for a long time,
Your key point "Eliminate one half" has cleared my confusion.
Thank you so much Striver
We never move backward bcoz we have Take You Forward😇
That's a good one 😁
little cringe brother.
@@surendharv795 ok so called mature sigma boy
The best explanation I have found for this problem.
Alog is very simple now
1. Identity the sorted half.
2. Check if the target lies in the sorted half.
Thats it you need to do this two things only.
Ig after solving like 15 BS problems, that's somewhat how all BS qs probably are.
Divide search space into two halves
Use some condition to eliminate either of the half from the search space
None can compete with this man....!!! Simply amazing 👏. Great Work Striver Bhaiyya
#DSA ka baap.
The best thing about you is that you are not paid and spreading knowledge to all the aspirants...
I think people should pay for this next level quality content.
@@iamnoob7593 haa...if u wish to.. then plss donate that money to some nearby ngos.
00:24 Problem statement
01:06 Example
01:43 Solution-01 (Linear Search)
02:21 Solution-02 (Binary Search)
05:00 Dry-run
11:42 Pseudocode
15:17 Code
15:28 Complexity
09:56 reaction lol
Correct
nalla bc
@@epsaepsit4645hahahahaha
what an absolutely great explanation. i watched another video before this and it was so convoluted for no reason. yours is so simple and easy to grasp
The one who are selling just their courses and making abundant money are getting more and more fame and heavily recognised today, but the person who truly creating impact is just not even known by everyone today, But anyway thank u so much striver bhaiya , for this great quality content , i wish you will be respected by every cs student of india one day !!
here after love babar lec - 14 for rotated sorted array he is using the concept of pivot element which is little messy
but striver what a lovely lovely explanation
in 1 go i understood and coded it myself
I learned recursion stack and queues from him , he's not a good teacher .
Yep that's not intuitive as this the striver's approach is
honestly I was very confused and demotivated after watching Rohit negi sir's explanation in paid course , i spent 2 hour to understand this problem but could not get it , after watching strivers explanation i get it only after single iteration. thanks a lot . now i am going to follow strivers AtoZ DSA
09:56 seriously i watched this many times to see your expression 😄
Yeah and The little smile when he continued... so cute ❤
that,s nice on which lecture you are currently
@@yoongicorn7973
yk striver is a cutie....😉😉
Mujhe mera mele m khoya hua bhai mil gya because our thoughts are same 🤣
Notes for me☺
As we get our mid at any index checks arr[num]==target if it satisfies return here.
After that
Case 1>
Array is left sorted(we check it by standing on mid),
==>Checks where our target lies in sorted(between low to mid ) or outside it by using
if(arr[low]=target)
if it lies inside this it indicates we need to collapse window by taking high to mid -1 otherwise low to mid+1
Case 2>
Array is right sorted similarly we check for it and updates our low and high accordingly
if we never get it we return -1 to it
One of the best explanations for this problem on the internet!
Thank You Raj Vikramaditya.
I am a scaler student , i fond of Your teaching skills more than scaler instructors.
Understood bhaiya , thw way of teching is another level, I don't have words to express my feelings. Thanks a lot, bhaiya!!!
one small correction in the code it will fail if the array is [3,1] and target = 1
because of code in line no 9 i.e k
No wrong, let me proove , low = 0 , high = 1 , mid = 0 , Now check if arr[low]
crazy concept striver ! I'm just loving your binary search playlist!!!
Looked at neetcode video, then yours. His explanation was a bit confusing and had to do some examples to understand it. Yours almost made it a regular easy binary search
Finally understood this problem. Every time I saw rotated sorted array or binary search in general I always skipped.
Thankyou for providing this course for free bro.
Can't find better explanation than striver .
what i did was i found the starting point using similar approach of binary search then applied binary search from that point...but this approach is goated
Amazing video, very good explanations, took sometime to understand but went through it again and again to understand it completely. Thanks for making such quality content Striver Bhai
Understood Please keep consistent and eventually complete the series of A to Z DSA Course....
Thank You
everyone just try dry run after you complete video after your understanding, it really in understanding still better. try ittt
Understood. The best explanation on youtube for this problem..
you are the best teacher I finally understood this problem thank you so much
YOU Can understand very well and i see a many video but my concept is not clear but just i see that video which would be clearly the concept very easily
mann unbelievable intuition and explanation!! loved it !!! understood completely
Great Raj bhai... you deserve to be in elite class.
keep rocking
best possible understanding through the BS playlist!
"Identify the sorted half" thank you
Understood! This man is a legend...
Understood! Super fantastic explanation as always, thank you so so much for your effort!!
Your explanation was much better than neetcodeio, thanks for explaining in such a detail. I was really missing the point to identify sorted part.
Can you please tell me what app you are using for pencil work.
Understood as always! The intuition/approach is just awesome🤩. Spellbound!
Understood! What a simple and affective explaination
1 QUESTION : will this approach/code work in the case of left rotated array also?? bacause here you explained for right rotated example.
Yes , same code will be there for left rotared.
bro the way you explain is just amazing thanks a lot
This great quality content for free !!! Amazing work , please keep making these great videos 👏👏👏👏
What an explanation bro..
You are our lives savior 🙏🙏
Only because of you I am loving DSA
Best explanation so far in binary search
Elimination is key - GOLDEN WORDS
bhaiya bhot bhot bhot hi aacha genuinely , bhot pyara samjhaya, too good!
When we say that val @low < val @high means array is sorted, how about the case when the array is reverse sorted and rotated somewhere?
Any thoughts on this corner case not passing: ARR=[3,1], target:1, Why is that? How to generalize the solution?
Other than that, beautiful explanation charm💯💯
thank you so much sir...respect for your amazing efforts...really no one teaches better than you... raj cum striver..i wish for your long life and happiness..
Understood, Tq for this great help by teaching in youtube for free
Got clearity that what is the main aim of binary search
striver's explanations are the best
Great video as always. Can there be a point in the sub array where both the halves are sorted.
you may right is wrong at 14.09 min. As far my understanding high should be high = mid not hing = mid-1 as you are using equal
Totally understood.your teaching is superb.thank you
quality GOD LEVEL 🔥 🔥
Hats off to you❤
Thank u for such a great explaination
Understood! watching your lectures and taking dsa notes, during college classes 😂❤ (17/8/24)
Understood,Thanks stiver for this amazing video.
great explanation buddy !
This is the best explanation
what"s your key secert key behind this sir i,e that much fluent in DSA 🤗
9:58 what a expression ;) mtlb mza sa aagya😆
understood sir
9:57 sir is so much excited
best explanation ever
understood
Thank you striver for making things easy...
Very well explained 👏🏻👏🏻
Can anyone share the video link for peak element ?
You have perform binary search in sorted array ( keeping ascending order ) in mind. Am I right? This will not work if array is sorted ( can be in ascending /descending ) order ( not known before hand ). Correct me if I am wrong.
Best explanation💯
What about the test cases 2222212 and 212222 😢
Amazing explanation sir 😇!
Great help you are doing
Understood :)
Understood bro!! Ur a gem!
9:56
Perfect reaction 😂
understood
Thankyou for clear explanation. Loved it.
Understood well thanks for this valuable video sir
Understood, thanks for your efforts!
other method to solve is first find pivot element and then apply binary search accordingly either on left or on right side based on checking target element with pivot element using assignment operator.
worst case wil be O(N) in this.
no in worst case scenario it wont be O(N), because once you find the pivot, you can either binary search on the left half or the right half, so you need 3 binary searches in total, one for finding the pivot, one for searching on the left half and one for searching on the right half@@anshulgupta2136
Love you bhaiya . You are my inspiration ❤
we can do like this also
int search(vector& nums, int target) {
int low,high,mid;
low = 0;
high = nums.size()-1;
while(low
This looks like a combination of binary search used along with linear search. Theoretically, time complexity of your code is a little higher.
Great explanation.
Greatly explained 👏👏
Love the explanation. THanks
woww what a great explanation
dill se thank you!
watching this on 0.75x playback speed feels like I'm watching a drunk person explaining me how to solve this problem.
thanks for the explanation
understood done and dusted
Nice Explanation!👍
Understood striver bhaiya
sir Best explanation Thanks!!
understood nicely
Great Explaination
Absolutely understand ❤