JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.util.*;
public class Program
{
public static int[] perfectSquares(int param) {
List<Integer> list = new ArrayList<>();
double sq;
for(int j = 1; j < param; j++) {
sq = Math.sqrt(j);
if(sq == (int)sq)
list.add(j);
}
int[] res = new int[list.size()];
for(int i = 0; i < res.length; i++)
res[i] = list.get(i);
return res;
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run