链接:https://leetcode.com/problems/sqrtx/
Question
Given a non-negative integer x, return the square root of x rounded down to the nearest integer. The returned integer should be non-negative as well.
You must not use any built-in exponent function or operator.
- For example, do not use
pow(x, 0.5)in c++ orx ** 0.5in python.
Example 1:
1 | Input: x = 4 |
Example 2:
1 | Input: x = 8 |
My Answer
1 | var mySqrt = function(x) { |
My Answer’s Performance
