Skip to content

Commit e4b7202

Browse files
author
Chris Wu
committed
no message
1 parent 02cbe89 commit e4b7202

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

problems/sqrtx.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,8 @@ def isAns(a):
2727
return -1
2828

2929

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.
3430

35-
Time complexity: O(LogN).
36-
Space complexity: O(1).
37-
"""
31+
#2020/7/23
3832
class Solution(object):
3933
def mySqrt(self, x):
4034
l = 0
@@ -49,4 +43,14 @@ def mySqrt(self, x):
4943
elif m_sqr<x:
5044
l = m+1
5145
else:
52-
r = m-1
46+
r = m-1
47+
48+
49+
"""
50+
The answer must always be in l~r.
51+
In every iteration, we test the m, `m_sqr==x or (m_sqr<x and x<(m+1)**2)`.
52+
If not the answer, we adjust l or r.
53+
54+
Time complexity: O(LogN).
55+
Space complexity: O(1).
56+
"""

0 commit comments

Comments
 (0)