Guess Number Higher or Lower

Easy
Searching Binary Search

Binary search: given n and target, output the target. Simulate: compare target to mid.

Constraints

1 ≤ n ≤ 2^31-1

Examples

Example 1:
Input: 10 6
Output: 6
Example 2:
Input: 1 1
Output: 1
▲ Console
📱

Install Talent Enrich

Get instant access to jobs and career tools on your device.