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

Published: 18 May 2021
on channel: Pepcoding
19,952
778

Please consume this content on nados.pepcoding.com for a richer experience. It is necessary to solve the questions while watching videos, nados.pepcoding.com enables that.

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).
2. nums is rotated at an unknown pivot index k (0 is less than equals to k && k is less than nums.length) such that the resulting array is [nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nums[k-1]] (0-indexed). For example, [0,1,2,4,5,6,7] might be rotated at pivot index 3 and become [4,5,6,7,0,1,2].
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)


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


For detailed information and other exercises, VISIT: www.pepcoding.com

Have a look at our result: https://www.pepcoding.com/placements​
Follow us on our FB page:   / pepcoding​  
Follow us on Instagram:   / pepcoding​  
Follow us on LinkedIn:   / pepcoding-education  


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

#BinarySearch #Array #leetcode33 #SearchingAndSorting

For a better experience and more exercises, VISIT: https://www.pepcoding.com/resources/o...

Have a look at our result: https://www.pepcoding.com/placements

Follow us on our Youtube page:    / pepcoding  

Follow us on our FB page:   / pepcoding  

Follow us on Instagram:   / pepcoding  

Follow us on LinkedIn:   / pepcoding-education  

Follow us on Pinterest:   / _created  

Follow us on Twitter: https://twitter.com/home

.
.
.
Happy Programming !!! Pep it up 😍🤩
.
.
.
#pepcoding #code #coder #codinglife #programming #coding #java #freeresources #datastrucutres #pepcode #competitive #competitiveprogramming #softwareengineer #engineering #engineer


Watch video Search in Rotated Sorted Array | Leetcode 33 Solution | Searching and Sorting online without registration, duration hours minute second in high quality. This video was added by user Pepcoding 18 May 2021, don't forget to share it with your friends and acquaintances, it has been viewed on our site 19,952 once and liked it 778 people.