This is simple solution for Perfect number but I am facing timeout for number like "999,999,991". Anyone can explain how to reduce time complexity from O(n) ??

```
public class Solution {
public boolean checkPerfectNumber(int num) {
//ArrayList<Integer> divisor = new ArrayList<Integer>();
int sum=0;
boolean flag = true;
for(int i=1;i<num;i++){
if(num%i == 0){
sum = sum + i;
if(sum > num){
flag = false;
break;
}
}
}
if(sum<num)
flag = false;
return flag;
}
}
```