Next greater number with same digits
Given a number, how do we find the next greater number with the same digits? For example if the given number is 123, the next greater number with the same digits is 132. Similarly for 23876, the output is 26378. If all the digits of the number are in decreasing order (Eg. 54321), there…