Dsa
Binary Search
Medium
Temperature Anomaly Detection
A meteorological station records daily temperatures over a month (30 days). You are tasked with identifying whether a certain temperature was recorded at least once during the month.
Input Format:
- The first line contains an integer t (1 <= t <= 30), the number of recorded temperatures.
- The second line contains t space-separated integers representing the daily temperatures (in Celsius). These temperatures are sorted in ascending order.
- The third line contains an integer q (1 <= q <= 50), the number of temperature queries.
- The next q lines each contain one integer representing a temperature to check.
Output Format:
- For each query, print "Present" if the temperature was recorded, otherwise print "Absent".
Example:
Input:
6
15 18 20 23 26 29
3
18
22
26
Output:
Present
Absent
Present
Key concepts
binary_searcharrayssearch
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