C++ program to find the next greatest number from the same set of digits
As clear from the name we have to find a number which is smallest in all the number greater than the given number with same set of digits.
If n = 123456
Then the next number greater than this is 123465
If n = 7531
Then no number is possible which is greater than this with same set of digits.
Same set of digits means that we can only use 7,5,3,1 to form a new number as given in the above example.