Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f9b1444

Browse files
refactor 367
1 parent 885c63c commit f9b1444

File tree

1 file changed

+11
-8
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+11
-8
lines changed
Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.fishercoder.solutions;
22

33
/**
4+
* 367. Valid Perfect Square
5+
*
46
* Given a positive integer num, write a function which returns True if num is a perfect square else False.
57
68
Note: Do not use any built-in library function such as sqrt.
@@ -16,14 +18,15 @@
1618
*/
1719
public class _367 {
1820

19-
public boolean isPerfectSquare(int num) {
20-
long i = 1;
21-
long temp = 1;
22-
while (temp < num) {
23-
i += 2;
24-
temp += i;
21+
public static class Solution1 {
22+
public boolean isPerfectSquare(int num) {
23+
long i = 1;
24+
long temp = 1;
25+
while (temp < num) {
26+
i += 2;
27+
temp += i;
28+
}
29+
return temp == num;
2530
}
26-
return temp == num;
2731
}
28-
2932
}

0 commit comments

Comments
 (0)