Dsa
Binary Search
Warm-up
The Growth Chart Insertion
A botanist tracks the height of a rare plant over several weeks, recording it in a sorted list. They want to insert a new height reading H into the list while maintaining the sorted order. If the height H already exists, it should be placed at the index of the first occurrence of that height. Find the index where H would be inserted.
Example:
Input:
5 18
10 15 20 25 30
Output:
2
Key concepts
binary_searchindex_finding
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