LintCode 141. Open root JavaScript algorithm for x

description

Implement the int sqrt(int x)function to calculate and return the square root of x.

Sample

- 样例 1:
	输入:  0
	输出: 0


- 样例 2:
	输入: 3
	输出: 1
	
	样例解释:
	返回对x开根号后向下取整的结果。

- 样例 3:
	输入: 4
	输出: 2

challenge

O(log(x))

Parsing

sqrt=x=>parseInt(Math.sqrt(x))

operation result

Insert picture description here

Guess you like

Origin blog.csdn.net/SmallTeddy/article/details/108724639
Recommended