Dsa
Binary Search
Easy
Search in Infinite Sorted Array
You are given an infinite sorted array where you can only access the element at a specific index. Your goal is to find the target value using a modified binary search approach.
Input Format:
- The first line contains an integer target (1 <= target <= 10^9).
Output Format:
- Print the index of the target if it exists in the infinite array, otherwise print -1.
Example:
Input:
5
Output:
4
Key concepts
binary_searcharrayinfinite
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