Created
April 4, 2022 03:00
-
-
Save zwongeer/6874b40835416131d4c3561bb3862532 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://leetcode-cn.com/problems/guess-number-higher-or-lower/ | |
/** | |
* Forward declaration of guess API. | |
* @param num your guess | |
* @return -1 if num is lower than the guess number | |
* 1 if num is higher than the guess number | |
* otherwise return 0 | |
* int guess(int num); | |
*/ | |
class Solution { | |
public: | |
int guessNumber(int n) { | |
return (size_t)partition_point((uint8_t*)1, (uint8_t*)n, [] (const uint8_t& i) { | |
return guess(size_t(&i)) == 1; | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment