Question bank › Binary Search
Dsa Binary Search Easy

Temperature Recorder

You have recorded daily temperatures for a week in Celsius, and the temperatures are sorted in ascending order. You need to check if a specific temperature was recorded during that week. If yes, print the index where it occurs; if it doesn't exist, print -1. Input: The first line contains an integer n (7). The next 7 lines contain the recorded temperatures. The last line contains the target temperature to search for. Output: Print the index (0-based) of the target temperature or -1 if not found. Example: Input: 7 15 18 20 22 25 30 35 20 Output: 2

Key concepts

binary_searcharrayssearching

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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.