mirror of
https://github.com/devenperez/leetcode.git
synced 2026-06-13 14:57:08 +00:00
11 lines
257 B
Python
11 lines
257 B
Python
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)
|