Question bank › Binary Search
Dsa Binary Search Warm-up

Temperature Conversion

You are given a list of temperature values in Celsius, sorted in ascending order. Write a program to convert a given Fahrenheit temperature to Celsius and find the closest Celsius temperature in the list. If two Celsius temperatures are equally close, return the smaller one. Input format: - The first line contains an integer n (1 ≤ n ≤ 1000) indicating the number of temperatures. - The second line contains n space-separated floats representing temperatures in Celsius. - The third line contains a float representing the temperature in Fahrenheit. Output format: - Print the closest Celsius temperature to the given Fahrenheit temperature. Example: Input: 5 -10 0 10 20 30 50 Output: 10

Key concepts

binary_searcharraytemperature

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.