```
public boolean isPerfectSquare(int num) {
if(num==1) return true;
long i=2;
while(i*i<=num && (i*i<Integer.MAX_VALUE)){
while(num%(i*i)==0)
num/=i*i;
if(num==1) return true;
i++;
}
return false;
}
```