c 2b 2b convert integer to digits 2c as vector

Solutions on MaxInterview for c 2b 2b convert integer to digits 2c as vector by the best coders in the world

showing results for - "c 2b 2b convert integer to digits 2c as vector"
Maja
11 Jan 2018
1// Convert integer to vector of digits
2vector<int> int_to_vector(long long n) { 
3    vector<int> vec;
4    while (n != 0) {
5        vec.push_back(n%10);
6        n /= 10;
7    }
8    reverse(vec.begin(), vec.end());
9    return vec;
10}