Time: 2026 ms (16.44%), Space: 13.8 MB (50.88%) - LeetHub

This commit is contained in:
Deven
2023-01-29 09:58:01 -05:00
parent 7a8c7ef2df
commit fc901a116d
+10
View File
@@ -0,0 +1,10 @@
class Solution:
def mySqrt(self, x: int) -> int:
nextOdd = 1
# Represent x as a sum of odd numbers
while x >= nextOdd:
x -= nextOdd
nextOdd += 2
return int((nextOdd - 1) / 2)