Question bank › Binary Search
Dsa Binary Search Warm-up

Find Closest Number

Write a function to find the closest number to a given target in a sorted array. If there are two numbers equally close to the target, return the smaller number. Input Format: - The first line contains space-separated integers (sorted array). - The second line contains an integer (target). Output Format: - The closest number to the target. Example: Input: 1 3 5 8 10 7 Output: 5

Key concepts

binary_searcharraysearch

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.