Search in Rotated Sorted Array | Leetcode 33 Solution | Searching and Sorting

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

NADOS also enables doubt support, career opportunities and contests besides free of charge content for learning. Question Statement:
1. There is an integer array of nums sorted in ascending order (with distinct values).
3. Given the array nums after the rotation and an integer target, return the index of the target if it is in nums, or -1 if it is not in nums.
4. You must write an algorithm with O(log n) runtime complexity.

Topic: #BinarySearch #leetcode33 #SearchingAndSorting

Used #DataStructure: #Array

#TimeComplexity: O(log n)

#SpaceComplexity: O(1)

---------------------------------------------------------------

----------------------------------------------------------------

#BinarySearch #Array #leetcode33 #SearchingAndSorting



.
.
.
Happy Programming !!! Pep it up 😍🤩
.
.
.
#pepcoding #code #coder #codinglife #programming #coding #java #freeresources #datastrucutres #pepcode #competitive #competitiveprogramming #softwareengineer #engineering #engineer
Рекомендации по теме
Комментарии
Автор

This is the only place the where the intuition behind approach along with approach is taught. Best tutorials!!!

surendrapandey
Автор

once approach is clear we are able to code.and in this problem I see the Explaination are really simple.Thank you for such great Explaination.

tusharsapate
Автор

adding one more fav teacher in my list

abhishekthakur
Автор

You're awesome ma'am, In fact whole pepcoding family is awesome.

utkarshtripathi
Автор

Initially I felt its tough question, but the way of explaination in really such great simpler manner. i dont have any confussion after seeing it...thank you mam.

nileshbahetwar
Автор

yrr ye pepcoding wale bnde itna shi padhate hai

clevercoderjoy
Автор

Thank you for this. Excellent approach, idea and the solution. Very well explained. Keep up the good work.

nigeldias
Автор

Most simple solution and best explanation!

ayushbajaj
Автор

i cant tell u maam how good u r in explaing 🔥

imi
Автор

Understood the concept very easily. Thanks

kshitijpandey
Автор

Her explanation is gold. how do i take her live course (in any upcoming batches)?

onceajordan
Автор

Python
class Solution:
def search(self, nums: List[int], target: int) -> int:
lo = 0
hi = len(nums)-1
while lo <= hi:
mid = (lo+hi)//2

if nums[mid] == target:
return mid
elif nums[lo] <= nums[mid]:
if target >= nums[lo] and nums[mid] > target:
hi = mid - 1
else:
lo = mid + 1
elif nums[hi] >= nums[mid]:
if target <= nums[hi] and nums[mid] < target:
lo = mid + 1
else:
hi = mid - 1
return -1

ialgorithms
Автор

Best explanation 🔥. Thank you so much 🙏

sakshiaggarwal
Автор

thanks ma'am, understood the concept very well

irfanquader
Автор

mam, please also cover the questions based on abstract binary search 🙏

kundankumar
Автор

arr[mid]<=arr[high] //this part will be sorted...this save my life. In..in Leet code it is not there.... many many thanks mam

democratcobra
Автор

nice explanation maam please make more videos

letsdoeverythinginoneweek
Автор

Minimum limit of ball in bag leetcode ..plz solve this question

shubhamchavan
Автор

Ma'am also take some question of abstract binary search.

SachinKumar-zyzr
Автор

Sir, a humble request can you please make a video on all the algorithms topic-wise, we should learn for interview and competitive coding. Please 🙏

aviral