diff --git a/69-sqrtx/69-sqrtx.py b/69-sqrtx/69-sqrtx.py new file mode 100644 index 0000000..d9f9446 --- /dev/null +++ b/69-sqrtx/69-sqrtx.py @@ -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)