Please comment understood and give us a like if you got everything :)
@FactFactoryCentral Жыл бұрын
In this code, isn't the worst case O(N). If all elements are same, and the element to be searched is not there in the array. Example: [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3], target: 4 Is O(N) the best that can be done if we have duplicate elements ?
@sudhanshushekhar4222 Жыл бұрын
understood
@venup2813 Жыл бұрын
Understood
@abhisheksinghmehra9576 Жыл бұрын
Understood
@365tage910 ай бұрын
Understood. You are a genius.
@hardikpatel3527 ай бұрын
there are lots of paid courses are available and many are upcoming but none of them is such in-depth and free like striver's A to Z dsa , Thanks a lot raj sir 🙇🏿♂🙇🏿♂
@SumitSingh-dc8pm11 ай бұрын
You just are a legend. Hat's off to you man. Loved your content. You start from basics and made this concept a cakewalk. Huge Respect for you.
@Mr.Manoj1Ай бұрын
Understood! You are a savior to people who struggle in DSA (im one of them) and I cant thank you enough.
@lshuarckymaАй бұрын
TIP BY STRIVER AT THE END: if you get questions envolving duplicates then try to solve them as unique element based and modify the code where the condition fails , for ex here it breaks at identifying the sorting portion
@ArdentMusicLover4 күн бұрын
brilliantly explained, both part 1 and par 2. Thank you, Striver!
@LearnwithEase2010 ай бұрын
Becoming your bigger fan day by day! Hats to your explanation
@momentcoder3 күн бұрын
Understood, solved the a2z sheet by 19%, thank you for the lovely content. 💌
@mehulthuletiya497 Жыл бұрын
Time-Stamps: 00:32 Problem Statement 00:50 Recap: Search Element in Rotated Sorted Array I 01:28 Why this problem different from previous 05:38 Explanation & Approach Start (Search Element in Rotated Sorted Array II) 10:09 Code 10:19 Complexity 11:41 Tip to solve problem
@reshmah1497Ай бұрын
Really understood the concept. Thanks much for teaching very well.
@Anshydv3 Жыл бұрын
the best explaination , i have ever seen on binary Search , LOVE YOU BRO ❣
@depavathnareshnaik55846 ай бұрын
Thank you for the excellent instruction on BS. Your clear explanations and engaging teaching methods really helped me grasp the concepts thoroughly. I feel much more confident in my understanding now. I appreciate your dedication and support!
@anishaa32984 күн бұрын
the best explanation thus far
@stith_pragya10 ай бұрын
UNDERSTOOD.........Thank You So Much for this wonderful video.........🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
@akbunofficial1281 Жыл бұрын
Better way to avoid the edge case of arr[mid]=arr[low]=arr[high] is to check the right sorted first , this will make the code more efficient
@manusklm11613 ай бұрын
Really? Can you explain with an example?
@djinnGamingLive2 ай бұрын
I don't think that will work. Even if we check the right sorted list first we need to know about the order of the first, middle and last element before that so we can rule out the possibility of them being equal.
@ravalik861110 күн бұрын
Heartful thanks to you bro......Your are doing a wonderful job by spreading the knowledge you have
@venkatsaireddy1412 Жыл бұрын
You are always the best bro, Thank you for clear explanation.
@cinime Жыл бұрын
Understood! Wonderful explanation as always, thank you very very much for your continuous effort!!
@HarshKumar-ip5nr Жыл бұрын
Understood the intuition and approach. Thanks for the series.
@prthms_10 ай бұрын
Understood.... Thank you so much for this wonderful Video❤❤
@prathambhushan48594 ай бұрын
didn't studied anyhing since last week, but starting again and gonna complete this in this week
@VikashKumar-tg3ot7 ай бұрын
Understood very well,Now i able to code my self before watching solution.Thanks striver bro.
@vipinamar8323Күн бұрын
Awesome, your videos are a great resource. Thank you sir.
@darshilmodi68515 ай бұрын
I truly appreciate your detailed explanation! To contribute to the community's knowledge, I encountered a situation where the original logic using low++ and high-- to handle duplicates wouldn't work. Here's a specific test case that demonstrates the issue: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1]. Fortunately, a simple fix exists. Instead of decrementing both low and high, we can simply increment low like this: low++. This modification allows the code to function correctly.
@srujangajjala26585 ай бұрын
ur modification isnt working for ur test case bro
@srujangajjala26585 ай бұрын
there is some error in coding ninjas, i ran the same code in offline compiler with ur test case it returned true only, in coding ninjas its returning false
@t3ch_r4id4 ай бұрын
I have submitted the code in coding ninja successfully the problem is if you carefully observe the question it states that array will be right rotated not left rotated 💡
@aishezsingh70044 ай бұрын
@@t3ch_r4id His Testcase is achivable by left rotating at 5th index
@monishamadu3 ай бұрын
It worked for me when I call the recursive method by just incrementing lower point, instead of continue.
@prajaktamhetre3010Ай бұрын
best course and I just love ur videos
@AppaniMadhavi9 ай бұрын
The code for the rotated sorted array I is also worked for rotated sorted array II in coding ninjas, but coding ninjas didn't provided all edge test cases.
@harshvardhansankpal7167 ай бұрын
yup in leetcode, that edge case of 2 elements is covere [ 3, 1 ] here high crosses low
@nishanthcodes4576 Жыл бұрын
This code complexity is O(N). I understand that, this is just to reinforce BS concept, but technically this becomes linear search. I would suggest, just reject the right part of array if the critical condition arrives. ie) if( ar[mid[ == ar[low] == ar[high]) then high = mid -1, simple.. now this code is O(logn). For people who can't get me (coz of my bad english).. Here is the code ( submitted and it passed all cases ): while(l=arr[l]){ if(k>=arr[l] && k=arr[m] && k
@jineshnadar6409 Жыл бұрын
Fails for [1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1] 2 you can't say that your mid + 1 to high will not contain the target just because the arr[ low ] == arr[ mid ] == arr[ high ] Target can be in left half or it can be right half depending on elements and rotations you've made
@simarpreetsingh72353 ай бұрын
@@jineshnadar6409exactly, his code passed because of lesser test cases
@arunsagarsa36136 ай бұрын
this guy is a gem! Nothing more to say.
@ramitroshan12316 күн бұрын
Thank you! for such an amazing explanation :)
@lakshmij60678 ай бұрын
Understood bro, Thank you so much...Learning so much from your videos
@dayashankarlakhotia4943 Жыл бұрын
Most intuitive and well explained
@JK-de2gh4 ай бұрын
hatsoff to u mann...put some python code als...becoz some beginners will learn it in python....
@vijaynag772311 ай бұрын
understood , thank you Striver.
@aakashsharma7802 ай бұрын
Again Understood Striver bhaiya ❤🔥🔥 , doing revision for placements..!!
@Sunil-ul1yg4 ай бұрын
You are a legend bro!
@AtulKumar-c4x7l Жыл бұрын
understood Thank u Striver for a wonderful explanation
@mohithadiyal6083 Жыл бұрын
THE best explanation
@Dipanshutripathi2407 Жыл бұрын
Understood every part of the video.
@aakashsharma780 Жыл бұрын
Understood Striver bhaiya ❤🙌
@yashraj589821 күн бұрын
understood , Great Exp. buddy !
@paragroy535911 ай бұрын
Great Content. Keep on making such videos.
@RIyaGupta-iz9iw7 ай бұрын
Best videos ever sir .. Understood
@brianjpeter98564 ай бұрын
Good Explanation Striver !
@champbehal8111 Жыл бұрын
Thnku striver❤
@abhinav_mittal4 ай бұрын
we can just use regular binary array and return true; in place of return m; if(arr[m] == target) and in the ending we can return false; rather then return -1;
@abhinav_mittal4 ай бұрын
and i might add using sort(arr.begin(), arr.end()); function in the starting of the code
@umangagarwal87264 ай бұрын
@@abhinav_mittal why in this question we cant return index and just returning true false?
@abhinav_mittal4 ай бұрын
@@umangagarwal8726 because in question it says to return true if found and false if not found
@umangagarwal87264 ай бұрын
@@abhinav_mittal yeah I know that but striver says in this question you cant return index using binary search that's why I am asking why this? As just remove true false and return mid or -1 it will give index
@abhinav_mittal4 ай бұрын
@@umangagarwal8726 yes but I think in the interview they can ask to solve using another method so that's why
@infinitecodes Жыл бұрын
Understood 😊
@adarshagarwal95086 ай бұрын
amazing waiting for the strings sums
@per.seus._ Жыл бұрын
UNDERSTOOD❤
@chirag71269Ай бұрын
Understood Striver ❤
@prasannamalatesha3887 Жыл бұрын
Great video, wonderful job explaining bro!!
@ramujanak963 Жыл бұрын
yes its understood striver 💙
@kingbadshah45210 ай бұрын
understood everything thanks striver!!!!
@KR_Technical-hj3bfАй бұрын
i can say one thing about you that no one dislike you
@priyanshunautiyal16628 ай бұрын
Understood bhaiya ❤
@culeforever5408 Жыл бұрын
understood
@Alwayspowerstar1439 ай бұрын
Understood Striver👌
@myproject6768 Жыл бұрын
Absolutely understand ❤
@infernogamer52 Жыл бұрын
Understood Bhaiya!
@muditsinghal60423 ай бұрын
What i did was simply trim one side down in starting, for example for 1 1 1 2 2 2 1 1 1, check if nums[0] is target, if not left++ until nums[left !]= nums[right], this will make it, 2 2 1 1 1 , now do the search
@charchitagarwal5893 ай бұрын
This will make the time complexity o( n )
@muditsinghal60423 ай бұрын
@@charchitagarwal589 no because we check if the array is sorted or not, only if it isn't sorted this will implement
@charchitagarwal5893 ай бұрын
@@muditsinghal6042 yeah o(n) is worst case time complexity
@mehrabhossain822511 ай бұрын
best explanation bro
@RaghavN-rd5zw7 ай бұрын
Understood!!! Thanks striver!!!
@ashokbabug40 Жыл бұрын
Amazing video bro really appreciated
@manishchahar91109 ай бұрын
Amazing work bro, keep rocking
@ayushirastogi9725 Жыл бұрын
understood love the course!!!
@NazeerBashaShaik7 ай бұрын
Understood, thank you.
@shrirambalaji2915 Жыл бұрын
Understood and you are awesome brother...
@samuelfrank1369 Жыл бұрын
Understood. Thanks a lot.
@tanmaychaudhary2801 Жыл бұрын
Thank you so much bhaiya ❤😇🙏
@Integral_MCАй бұрын
understood, thanks
@anuragprasad611610 ай бұрын
To solve this in O(log N), we can use if (arr[mid] == arr[high]) high = mid-1; That is, if arr[mid]==arr[high] we can be sure that the complete right half has elements = arr[mid] and it can be safely discarded.
@simarpreetsingh72353 ай бұрын
Nope 11111111211 Your logic will fail here
@amitjindar67063 ай бұрын
UNDERSTOOD
@amityadav-np1rk Жыл бұрын
Great explanation!!
@SAHIL-dq8je Жыл бұрын
Thanks bhaiya
@utsavseth6573 Жыл бұрын
Great lecture .
@selene87213 ай бұрын
Thank you so much!
@CodeMode9313 Жыл бұрын
shukriya habibi
@rahulpathak859 Жыл бұрын
Understood everything💯
@humanity7880 Жыл бұрын
understood!
@RaunitJaiswal-s9v2 ай бұрын
You know what life is too unpredictable not for everyone but for few it is
@oyeesharme3 ай бұрын
understood bhaiya
@motivatewithme1233 ай бұрын
STRIVER BHAII 💌
@lakshminarayana5500 Жыл бұрын
Understood
@nagavedareddy5891 Жыл бұрын
Thank u striver... ❤
@ESkp15 Жыл бұрын
Wow! Understood!
@Liftedmonk9 ай бұрын
buddy is a god
@abhisarsahay81363 ай бұрын
understood striver!!!!
@RaviKumar-sn6tu7 ай бұрын
Understood sir ...
@Bug-g5b4 күн бұрын
ty striver!
@arjitgautam365 Жыл бұрын
well explained. Appreciated
@ujjawalraj6096 Жыл бұрын
Understood everything
@YourCodeVerse11 ай бұрын
Understood✅🔥🔥
@David-kj7el5 ай бұрын
so the only problem is in the case of (arr[low] == arr[mid] == arr[high]) for that we do nothing just do low++ and high-- (that is trimming down the search space) one of the way to handle duplicates
@JothiprakashThangaraj4 ай бұрын
understood!!!! thanks a lot!
@shivanshchaturvedi2601 Жыл бұрын
Thanku
@Learnprogramming-q7f9 ай бұрын
Thank you bhaiya
@shubhamsharma-nb8yd Жыл бұрын
Instead of continue , you can change next if to else if ... that will also work :P
@music-loverFam3 ай бұрын
Understood☺
@ritikasingh54432 ай бұрын
thank you sir
@RAJSINGH-mr7hq Жыл бұрын
Superb. Understood!!
@sahulraj95369 ай бұрын
i followed a different approach for the special case if nums[low] == nums[mid] == nums[high] then i checked if mid to high is sorted but i checked it using linear search.