Last Updated: 9 Jan, 2021

# Search In Rotated Sorted Array

Easy

## Problem statement

#### Now, your task is to find the index at which ‘k’ is present in 'arr'.

##### Note :
``````1. If ‘k’ is not present in 'arr', then print -1.
2. There are no duplicate elements present in 'arr'.
3. 'arr' can be rotated only in the right direction.
``````

##### Example:
``````Input: 'arr' = [12, 15, 18, 2, 4] , 'k' = 2

Output: 3

Explanation:
If 'arr' = [12, 15, 18, 2, 4] and 'k' = 2, then the position at which 'k' is present in the array is 3 (0-indexed).
``````

##### Input Format
``````In the first line, two single-space separated integers ‘n’ and ‘k’, respectively.
The second line, ‘n’ single space-separated integers, denotes the array/list 'arr' elements.
``````

##### Output Format :
``````The only line contains the index at which 'k' is present in 'arr'.
``````

##### Note:
``````You do not need to print anything; it has already been handled. Just implement the given function.
``````

## Approaches

### 01 Approach

Naively traverse the array and find if ‘k’ is present in ‘arr’ or not. If ‘k’ is present in ‘arr’ return its index else return -1.