BackhardBinary Search

Rotated Array Minimal Element Solution

Problem Statement

Given a rotated sorted array of integers, find the index of the smallest element in the array.

Example 1
Input
[47, 19, 81, 31, 13, 29]
Output
4

Explanation: The smallest element is 19 and its index is 1.

Example 2
Input
[17, 27, 3, 5, 9, 11]
Output
2

Explanation: The smallest element is 3 and its index is 2.

Example 3
Input
[7, 8, 9, 1, 2, 3, 4, 5, 6]
Output
3

Explanation: The smallest element is 1 and its index is 3.

Constraints

  • 1 <= array length <= 1000
  • -10^4 <= array elements <= 10^4
  • All elements are unique
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free