Question bank › Binary Search
Dsa Binary Search Hard

Inventory Optimal Price Search

You are managing an inventory system where each product has a minimum price for a specific date. The price list for the next n days is sorted in non-decreasing order. Given a target date and a price, determine if there is a product that can be sold at that price or less on that date. Your program should read the number of days, the sorted list of prices, and the target price, and print 'Found' if such a price exists, or 'Not Found' otherwise. Input Format: - The first line contains an integer n (1 <= n <= 100,000) representing the number of days. - The next n lines contain integers representing the prices for those days. - The last line contains the target price. Output Format: - Print 'Found' if there is a price less than or equal to the target price, otherwise print 'Not Found'. Example: Input: 5 10 20 30 40 50 25 Output: Found

Key concepts

binary_searchsearchingarrays

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.