Guess Number Higher or Lower Problem
Guess Number Higher or Lower Problem — ExecCode Easy DSA Practice
Solve the Guess Number Higher or Lower problem on ExecCode. Free online easy DSA practice in Binary Search. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You have to guess which number I picked (the number I picked stays the same throughout the game). Your task is to compute the required answer and return the number that I picked. We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. Every time you guess wrong, I will tell you whether the number I picked is higher or lower than your guess.
Examples
Input {"n": 10, "pick": 6}; Output 6. Input {"n": 1, "pick": 1}; Output 1. Input {"n": 2, "pick": 1}; Output 1
Constraints
1 <= n <= 2^31 - 1 1 <= pick <= n
Practice Guess Number Higher or Lower free on ExecCode. Browse DSA problems, topic map, and placement guides.