← AlgoMindset 75

Guess Number Higher or Lower

Easy🎙 Interview me on this

🧠 Before you code — what pattern fits?

I picked a number between 1 and n. You call the provided guess(num) API: it returns 0 if num is my number, -1 if my number is lower, and 1 if my number is higher. Return the number I picked.

(n=10, pick=6) → 6

🎬 Video explanation · NeetCode

Your solution runs against 3 unit tests, including edge and large-value cases.

Loading...

Test console · 3 unit tests

Submit your code to run it against all 3 unit tests. Results appear here.

JavaScript, TypeScript & Python run sandboxed in your browser; other languages run on the execution server. Your code is saved locally as you type.