We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3c8f2e2 commit cf50a99Copy full SHA for cf50a99
src/main/java/com/fishercoder/solutions/_69.java
@@ -1,18 +1,13 @@
1
package com.fishercoder.solutions;
2
3
-/**
4
- * 69. Sqrt(x)
5
- *
6
- * Implement int sqrt(int x).
7
- * Compute and return the square root of x.
8
- */
9
-
10
public class _69 {
11
public static class Solution1 {
12
- /**A few key points:
+ /**
+ * A few key points:
13
* 1. all variable use long type, otherwise overflow, just cast to int before returning
14
* 2. left start from 0, not 1
15
- * 3. right start from x/2 + 1, not from x*/
+ * 3. right start from x/2 + 1, not from x
+ */
16
public int mySqrt(int x) {
17
long left = 0;
18
long right = x / 2 + 1;
0 commit comments