
NewsTools
Guess the Number
via Dev.to BeginnersSaranya R
Approach Explanation (ノ◕ヮ◕)ノ*:・゚✧ I used binary search between 1 and n. I guessed the middle number (mid). If the guess was correct (res == 0), I returned it. If the guess was too high (res == -1), I moved the search to the left half. If the guess was too low (res == 1), I moved the search to the right half. This process continued until I found the picked number. Method Used:ヽ(  ̄▽ ̄ )ノ Binary search technique Midpoint guessing API feedback In‑place logic Efficient runtime
Continue reading on Dev.to Beginners
Opens in a new tab
6 views


