Guess Number Higher or Lower LC374
- 📅 2026-11-05T06:15:04.690Z
- 👁️ 54 katselukertaa
- 🔓 Julkinen
# Guess Number Higher or Lower (LeetCode 374): Interview Notes
## Problem
Pick a number in 1..n. An API returns -1/1/0 for too high / too low / correct. Find the number.
## Approach
Binary search the range. Midpoint guess; shrink high or low from the API result until 0.
## Complexity
Time O(log n), space O(1).
## Practice tip
State invariant clearly (answer always in [lo, hi]) — practice aloud with an [AI coding interview tool](https://www.linkjob.ai/).
*Disclosure: I work on Linkjob AI.*