Search in rotated sorted array | Leetcode #33

preview_player
Показать описание
This video explains a very important interview coding problem which is to search a target element given a originally sorted array in ascending order which has now been rotated. We are required to find the pivot element in just O(log N) time. I have explained 2 binary search approaches. The first approach finds the target element by first calculating the pivot element and then find the target element which takes 2 traversals of the given array. The second approach is better which solves the problem in just a single traversal of the array using binary search and this is the most optimal approach for this problem. CODE for BOTH approaches are present in the same CODE LINK file. If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful...CYA :)

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

Dude, I appreciate the detailed presentation, you should know that you are doing a great service !

arunraju
Автор

This video is extremely illuminating. We just need more videos like this one. Leetcode discussion always talks about the final optimized solution where the thought process is invisible. This video demonstrates the thought process -> 2pass solution -> 1pass solution and finally helps everyone understand how the optimization occurs. Good job!

klausdupont
Автор

got an offer from Microsoft after learning from this channel. Thanks :)

babulbhanu
Автор

This was a great explanation! I've watched a couple of videos and read some explanations on Leetcode for this problem, but I still couldn't quite understand it. There were two things you said that really made it click for me:
1. There is always at least 1 half of the array where the values are increasing.
2. We want to find that half, and then see if the target is inside that subsection.

HanifCarroll
Автор

thanks I was gettin TLE in the first approach which I had thought by myself. Ur one pass solution really helped me :)

xacademia
Автор

From the 7th Minute onwards, this video is GOLD Jaha Pana Tussi Great Ho

vikramreddy
Автор

Looked at several other videos but still not clear. this one explains with great overall picture and logic ! thanks a lot !

denniskang
Автор

BEST explanation I've seen on Youtube for this problem. Thank you!

davidpham
Автор

Wow! I watched a lot of videos but I just could not wrap my head around it.. This explanation was the answer which I was looking for!!!!

UCAjryuRctKIGCxDkbubQ
Автор

i was really confused by the searching in the uniform approach at first but i realized that its easier to set the conditions for the uniform approach than the non uniform approach, thanks!

chloe
Автор

For dummies, your explaintion is always clear than ever. You deserve more subcribers. Thank you Tech Dose :)

jinny
Автор

one of the best application of binary search, you explained it very well, the approach without finding pivot element is best approach

Chandrakumar-ubuh
Автор

At 12:06, line 23 can also we written without checking target equal to mid elements. .ie

line 23 : if(target<nums[mid] && nums[left]<=target)
line 30 : if(target>nums[mid] && target<=nums[right])

No need to do equality checking for target with nums[mid].

by the way you are doing fabulous job, everyday solution of leetcode challenge is really helpful. keep posting it.

aditgulia
Автор

This explantation is greater than any others.

taocheng
Автор

A really good explanation. Could not imagine that this problem could be solved in this way as well! Appreciate the work.

ayushjain
Автор

It becomes so easy to understand the approach to solve problems by watching your videos. Thanks a lot for making it so easy for us to understand the solutions.

anshikagovil
Автор

This is best explanation from all other explanations I have seen/read for this problem.

abhishekmore
Автор

Sir, your channel deserves so much more attention and subs. Thank you.

priyankapardesiramachander
Автор

One of the finest explaination, Thank You!

roushansingh
Автор

just amazing ! A huge appreciation for you.

shaswatpandey