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
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console