# 103. implement Math.sqrt()

Share

medium - accepted / - tried

Math.sqrt() helps us getting the square root of a number.

Can your write your own `mySqrt()`

? You should return the integer part only, truncating the fraction part.

`mySqrt(0)// 1mySqrt(1)// 1mySqrt(2)// 1mySqrt(4)// 2mySqrt(NaN)// NaN`

Attention for the special case listed up in the spec.

**Follow-up**

What is time & space complexity of your solution ? Can you do better?