mirror of
https://github.com/devenperez/leetcode.git
synced 2026-06-15 09:57:09 +00:00
Time: 2026 ms (16.44%), Space: 13.8 MB (50.88%) - LeetHub
This commit is contained in:
@@ -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)
|
||||||
Reference in New Issue
Block a user