Question bank › Binary Search
Dsa Binary Search Medium

Stock Price Lookup

You are tracking stock prices for a certain company over time. Given a list of unique timestamps and their corresponding prices (sorted by timestamp), your task is to find the price at a given timestamp using binary search. If the timestamp is not present, return -1. Input Format: - The first line contains an integer p (1 <= p <= 1000), the number of price entries. - The second line contains p space-separated timestamps in ascending order. - The third line contains p space-separated stock prices corresponding to the timestamps. - The fourth line contains a timestamp to lookup. Output Format: - The price at the given timestamp, or -1 if not found. Example: Input: 4 1625034000 1625037600 1625041200 1625044800 100 101 102 103 1625041200 Output: 102

Key concepts

binary_searchlistsearch

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