Simple C++ solution without sorting


#1
vector<int> Solution::allFactors(int A) {
    vector<int> small, big;
    for (int i = 1; i*i <= A; i++) {
        if (A%i == 0) {
            small.push_back(i);
            if (A/i != i) big.push_back(A/i);
        }
    }
    vector<int> all(small);
    all.insert(all.end(), big.rbegin(), big.rend());
    return all;
}