[Solved] Forming the smallest number [closed]

[ad_1]

As others have pointed out sorting and removing duplicates is possible. But how about this algorithm (in pseudocode, implementation is left to the reader)?

bool contains(int x, int digit); // returns true if x contains digit in base 10 notation

int res = 0;
for (int digit = 0; digit <= 9; ++i) {
    if (contains(intput, digit)) res = 10 * res + digit;
}
return res;

1

[ad_2]

solved Forming the smallest number [closed]