Dsa
Binary Search
Easy
Find Median in Rotated Array
Given a rotated sorted array, write a function to find the median of the unique integers in the array. The median is the middle value of a sorted array. If there is an even number of elements, the median is the average of the two middle numbers.
Input format:
- The first line contains an integer n (1 <= n <= 1000), the number of elements in the array.
- The second line contains n integers, the rotated sorted array.
Output format:
- A single float representing the median of the array.
Example:
Input:
5
4 5 6 7 1
Output:
5.0
Key concepts
binary_searcharraymedian
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