###### STATUS
• Solved
• Unsolved

Showing:
Handle Score
@Ibrahim Nash 6420
@mb1973 5578
@Quandray 5231
@akhayrutdinov 5111
@saiujwal13083 4510
@sanjay05 3762
@kirtidee18 3673
@marius_valentin_dragoi 3522
@sushant_a 3459
@verma_ji 3412
Search an element in sorted and rotated array
Easy Accuracy: 50.0% Submissions: 11693 Points: 2

Given a sorted and rotated array A of N distinct elements which is rotated at some point, and given an element K. The task is to find the index of the given element K in the array A.

Example 1:

Input:
N = 9
A[] = {5 6,7,8,9,10,1,2,3}
K = 10
Output: 5
Explanation: 10 is found at index 5.


Example 1:

Input:
N = 3
A[] = {3,1,2}
K = 1
Output: 1

Complete Search() function and return the index of the element K if found in the array. If the element is not present, then return -1.

Expected Time Complexity: O(log N).
Expected Auxiliary Space: O(1).

Constraints:
1 ≤ N ≤ 107
0 ≤ Ai ≤ 108
1 ≤ K ≤ 108

### Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

#### My Submissions:

Search an element in sorted and rotated array