mirror of
https://github.com/devenperez/leetcode.git
synced 2026-06-13 03:27:07 +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