Skip to content

Commit 9ee2bd4

Browse files
authored
Create Sqrtx.py
1 parent f3d9515 commit 9ee2bd4

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Sqrt(x)/Sqrtx.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution(object):
2+
def mySqrt(self, x):
3+
"""
4+
:type x: int
5+
:rtype: int
6+
"""
7+
if x == 0:
8+
return 0
9+
10+
i = 0
11+
while i * i <= x:
12+
if (i + 1) * (i + 1) > x:
13+
return i
14+
i += 1

0 commit comments

Comments
 (0)