Dsa
Binary Search
Easy
Counting Rotations
You are given a rotated sorted array of distinct integers. Your task is to count the number of rotations that have been performed on this array, which is equivalent to finding the index of the minimum element.
Input Format:
- The first line contains an integer n (1 <= n <= 100000).
- The second line contains n space-separated integers representing the elements of the array.
Output Format:
- Print the number of rotations.
Example:
Input:
6
4 5 6 1 2 3
Output:
3
Key concepts
binary_searcharraycounting
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now