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 885c63c commit f9b1444Copy full SHA for f9b1444
src/main/java/com/fishercoder/solutions/_367.java
@@ -1,6 +1,8 @@
1
package com.fishercoder.solutions;
2
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.
@@ -16,14 +18,15 @@
16
18
*/
17
19
public class _367 {
20
- public boolean isPerfectSquare(int num) {
- long i = 1;
21
- long temp = 1;
22
- while (temp < num) {
23
- i += 2;
24
- temp += i;
+ public static class Solution1 {
+ public boolean isPerfectSquare(int num) {
+ long i = 1;
+ long temp = 1;
25
+ while (temp < num) {
26
+ i += 2;
27
+ temp += i;
28
+ }
29
+ return temp == num;
30
}
- return temp == num;
31
-
32
0 commit comments