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 02cbe89 commit e4b7202Copy full SHA for e4b7202
problems/sqrtx.py
@@ -27,14 +27,8 @@ def isAns(a):
27
return -1
28
29
30
-"""
31
-The answer must always be in l~r.
32
-In every iteration, we test the m, `m_sqr==x or (m_sqr<x and x<(m+1)**2)`.
33
-If not the answer, we adjust l or r.
34
35
-Time complexity: O(LogN).
36
-Space complexity: O(1).
37
+#2020/7/23
38
class Solution(object):
39
def mySqrt(self, x):
40
l = 0
@@ -49,4 +43,14 @@ def mySqrt(self, x):
49
43
elif m_sqr<x:
50
44
l = m+1
51
45
else:
52
- r = m-1
46
+ r = m-1
47
+
48
+"""
+The answer must always be in l~r.
+In every iteration, we test the m, `m_sqr==x or (m_sqr<x and x<(m+1)**2)`.
+If not the answer, we adjust l or r.
53
54
+Time complexity: O(LogN).
55
+Space complexity: O(1).
56
0 commit comments