Practice Guess Number Higher or Lower II
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
A secret number is chosen from 1 through n. A correct guess wins without a charge. Each incorrect guess x costs x dollars, and you are told whether the secret is higher or lower before guessing again. You lose if you cannot afford to continue. Return the smallest starting amount that lets you guarantee a win for every possible secret number.
Source: Guess Number Higher or Lower II on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
n = 10
16
# Example 2
n = 1
0
# Example 3
n = 2
1
Constraints
Related LeetCode Problems
Practice more problems similar to Guess Number Higher or Lower II.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.