Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/Blankj/awesome-java-leetcode
/ mySqrt
Method
mySqrt
src/com/blankj/easy/_0069/Solution.java:12–18 ·
view source on GitHub ↗
(int x)
Source
from the content-addressed store, hash-verified
10
*/
11
public
class
Solution {
12
public
int
mySqrt(
int
x) {
13
long n = x;
14
while
(n * n > x) {
15
n = (n + x / n) >> 1;
16
}
17
return
(
int
) n;
18
}
19
20
public
static
void
main(String[] args) {
21
Solution solution =
new
Solution();
Callers
1
main
Method · 0.95
Calls
no outgoing calls
Tested by
no test coverage detected