374 Guess Number Higher or Lower | Zero to FAANG Kunal | Searching in Arrays | Leetcode

Sdílet
Vložit
  • čas přidán 10. 09. 2021
  • 374 Guess Number Higher or Lower | Zero to FAANG Kunal | Searching in Arrays | Leetcode
    Problem link :
    leetcode.com/problems/guess-n...
    Course link:
    github.com/kunal-kushwaha/DSA...
    Complete Java + DSA + Interview Preparation + CP Course
    • Java + DSA + Interview...
    Hi, thanks for watching our video about 2D Arrays in Java
    In this video we’ll walk you through:
    - Brute Force
    - Efficient approach
    - Solution Code
    TIMESTAMPS
    Intro
    Explanation begins
    IDE solution
    ABOUT OUR CHANNEL
    Our channel is all about Programming. We cover lots of cool stuff such as solution to problems, concept explanation and tricks to master CP
    Check out our channel here:
    / @programmerszone
    Don’t forget to subscribe!
    CHECK OUT OUR OTHER Playlists
    GeeksforGeeks playlist:
    • GeeksforGeeks problems
    Complete C++ Course playlist:
    • Complete C++ playlist
    CodeChef Playlist:
    • CodeChef Problems
    HackerRank playlist:
    • HackeRank problems
    LeetCode problems
    • Leetcode problems Solu...
    FIND US AT
    www.waadanibhao.wordpress.com
    GET IN TOUCH
    Contact us on hopesalivenow@gmail.com
    374. Guess Number Higher or Lower
    Easy
    784
    2287
    Add to List
    Share
    We are playing the Guess Game. The game is as follows:
    I pick a number from 1 to n. You have to guess which number I picked.
    Every time you guess wrong, I will tell you whether the number I picked is higher or lower than your guess.
    You call a pre-defined API int guess(int num), which returns 3 possible results:
    -1: The number I picked is lower than your guess (i.e. pick is less than num).
    1: The number I picked is higher than your guess (i.e. pick is greater than num).
    0: The number I picked is equal to your guess (i.e. pick == num).
    Return the number that I picked.
    Example 1:
    Input: n = 10, pick = 6
    Output: 6
    Example 2:
    Input: n = 1, pick = 1
    Output: 1
    Example 3:
    Input: n = 2, pick = 1
    Output: 1
    Example 4:
    Input: n = 2, pick = 2
    Output: 2
    Constraints:
    1 = n = 231 - 1
    1 = pick = n
    Accepted
    222,423
    Submissions
    479,995
    #codechef #coding #python #hackerrank #programming #java #computerscience #coder #code #competitiveprogramming #machinelearning #pythonprogramming #algorithms #cpp #javascript #hackerearth #webdeveloper #geeksforgeeks #codinglife #leetcode #c #codeforces #engineering #codingmemes #programmer #hacker #programmingmemes #topcoder #webdevelopment #bhfyp #DSAwithKunal

Komentáře • 10