Skip to content

Commit 40ec471

Browse files
refactor 367
1 parent 1d519cc commit 40ec471

File tree

1 file changed

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

1 file changed

+11
-27
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,16 @@
11
package com.fishercoder.solutions;
22

3-
/**
4-
* 367. Valid Perfect Square
5-
*
6-
* Given a positive integer num, write a function which returns True if num is a perfect square else False.
7-
8-
Note: Do not use any built-in library function such as sqrt.
9-
10-
Example 1:
11-
12-
Input: 16
13-
Returns: True
14-
Example 2:
15-
16-
Input: 14
17-
Returns: False
18-
*/
193
public class _367 {
204

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;
30-
}
31-
}
5+
public static class Solution1 {
6+
public boolean isPerfectSquare(int num) {
7+
long i = 1;
8+
long temp = 1;
9+
while (temp < num) {
10+
i += 2;
11+
temp += i;
12+
}
13+
return temp == num;
14+
}
15+
}
3216
}

0 commit comments

Comments
 (0)