Tap here to switch tabs
Problem
Submissions

Problem: Guess Number Higher or Lower II

med
30 min
Try to solve the Guess Number Higher or Lower II problem.

Statement

We are playing a guessing game. The rules of the game are as follows:

  1. A number from 11 to n is chosen.

  2. You attempt to guess the chosen number.

  3. If you guess correctly, you win the game.

  4. If your guess is incorrect, you are told whether the chosen number is higher or lower than your guess, and you continue guessing.

  5. Each time you make an incorrect guess of value xx, you must pay \\x$.

Given an integer n, return the minimum amount of money required to guarantee a win regardless of which number is chosen.

Constraints:

  • 1≤1 \leq n ≤200\leq 200

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Guess Number Higher or Lower II

med
30 min
Try to solve the Guess Number Higher or Lower II problem.

Statement

We are playing a guessing game. The rules of the game are as follows:

  1. A number from 11 to n is chosen.

  2. You attempt to guess the chosen number.

  3. If you guess correctly, you win the game.

  4. If your guess is incorrect, you are told whether the chosen number is higher or lower than your guess, and you continue guessing.

  5. Each time you make an incorrect guess of value xx, you must pay \\x$.

Given an integer n, return the minimum amount of money required to guarantee a win regardless of which number is chosen.

Constraints:

  • 1≤1 \leq n ≤200\leq 200