Search Element In a Rotated Sorted Array | LeetcodeBS-4. Search Element in Rotated Sorted Array - I

preview_player
Показать описание

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

This playlist will be remembered in the history of Programming that there is someone who explains in such a way that the thing goes and fits in the middle brain and never moves to low or high part of the brain . It just remain there.

asheskhan
Автор

WTF MAN. THIS CHANNEL IS JUST GOD LEVEL IN TERMS OF EXPLANATIONS. Man I am going to donate to your channel. The best freaking channel for coding explanations on youtube.

meowmr
Автор

Great. I watched upto 4 videos struggling to understand. At last I found your video explained thoroughly. I'm super satisfied.

hereweare
Автор

This is the most lucid and intuitive explanation for this question. I managed to solve this problem watch this video only once...

NoName-iptt
Автор

I have watched multiple videos but this one has the clear explanation than all the others. thank you!!

dheerajvemula
Автор

i did two method
method 1 : p pass , find pivot and then do binary search
method 2: strivers method

Ace-exgg
Автор

The explanation is so awesome. I was just getting confused in between every time while coding this question. But then, I watched only 1/3rd of your video, and YAY! I got the whole approach and got the correct submission as well. Keep making content like this Sir!

indrakantd
Автор

Searched it on many places, but finally understood it here… thanks a lot!!

Techandcarsbeaste
Автор

I submitted this solution to leetcode
surprisingly linear search runtime was 3ms and binary search runtime was 11ms

shivamsiddharthasinghrajaw
Автор

mid nikalne k liye jo right shift operator ki trick use kri hai, vo bhot osm lgi
Thanks for explaining so well

honeysharma
Автор

Questions ka frequency badh gaya thanks bahiya

Nishant-iz
Автор

on youtube everybody taking the pivot element and then doing binary search
but strive bhaiya, I am here we can do it with different methods as well

mohitkumarbansal
Автор

Amazing... It's amazing!✨💯🤩
You are my favourite teacher from now on... Striver!🥳

somyasaxena
Автор

I have done code by myself but after saw your code it exactly looks Same =D !!

karanbhati
Автор

I just discovered this channel, God bless you man. I really appreciate

chukypedro
Автор

@take U forward

here after the last else condition
Do not miss to update Mid element mid = start + (end- start)/2
otherwise its gives only -1 for each testcase

mindpower
Автор

Hi Striver, just one clarification, why "equals to" has been used?
That is instead of <, > why we use <=, >=?

SuperWhatusername
Автор

int search(vector<int>& nums, int target) {
int low=0, high=nums.size()-1;
while(low<=high){
int mid=(low+high)>>1;
if(nums[mid]==target) return mid;
if(nums[low]<=nums[mid]){
if(target>=nums[low] && target<nums[mid]){
high=mid-1;
}
else low=mid+1;
}
else{
if(target>=nums[mid] && target<=nums[high]) low=mid+1;
else high=mid-1;
}
}
return -1;
}

this code works fine

diwakarkumar
Автор

damm mann.. no one can take place of striver understood
respect++

mindpower
Автор

Let's take the case:
A[5, 6, 1, 2, 3, 4], target =6
According to your algorithm if A[low]<=A[mid]-->this condition fails, so we'll slice the left half and make low=mid+1, now what about 6 in the left half?

ambarkansal