We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cad2b7c commit 2d1706aCopy full SHA for 2d1706a
Problems/10-Find-the-Distance-Value-Between-Two-Arrays/Find_the_Distance_Value.py
@@ -0,0 +1,25 @@
1
+# The guess API is already defined for you.
2
+# @param num, your guess
3
+# @return -1 if num is higher than the picked number
4
+# 1 if num is lower than the picked number
5
+# otherwise return 0
6
+# def guess(num):
7
+
8
+class Solution(object):
9
+ def guessNumber(self, n):
10
+ """
11
+ :type n: int
12
+ :rtype: int
13
14
+ min, max = 1, n
15
+ while min < max:
16
+ mid = (min + max) // 2
17
+ res = guess(mid)
18
+ if res == 0:
19
+ return mid
20
+ elif res < 0:
21
+ max = mid
22
+ else:
23
+ min = mid + 1
24
25
+ return min
0 commit comments