Skip to content

Commit cf50a99

Browse files
refactor 69
1 parent 3c8f2e2 commit cf50a99

File tree

1 file changed

+4
-9
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+4
-9
lines changed

src/main/java/com/fishercoder/solutions/_69.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
package com.fishercoder.solutions;
22

3-
/**
4-
* 69. Sqrt(x)
5-
*
6-
* Implement int sqrt(int x).
7-
* Compute and return the square root of x.
8-
*/
9-
103
public class _69 {
114
public static class Solution1 {
12-
/**A few key points:
5+
/**
6+
* A few key points:
137
* 1. all variable use long type, otherwise overflow, just cast to int before returning
148
* 2. left start from 0, not 1
15-
* 3. right start from x/2 + 1, not from x*/
9+
* 3. right start from x/2 + 1, not from x
10+
*/
1611
public int mySqrt(int x) {
1712
long left = 0;
1813
long right = x / 2 + 1;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy