Solution with sorting C++


#1
vector<int> Solution::allFactors(int A) {
vector<int> list;
for(int div = 1; div*div <= A; div++)
{
    if(A % div == 0)
    {
        list.push_back(div);
        if(div*div != A)
            list.push_back((int)(A/div));
    }
        
}
sort(list.begin(), list.end());

return list;

}