We're a place where coders share, stay up-to-date and grow their careers.
in C++ using the standard template library:
typedef unsigned long long ull; ull superSize(ull x) { vector<short> d; while(x > 0) { d.push_back(x%10); x /= 10; } sort(d.begin(), d.end(), greater<short>()); ull r = 0; for(auto i: d) r = r*10 + i; return r; }
in C++ using the standard template library: