Question: For any given number N, write a program to print the smallest possible number R by rearranging the same set of digits. Ze If the

 For any given number N, write a program to print the

smallest possible number R by rearranging the same set of digits. Ze

If the given number N is already the smallest possible number with

For any given number N, write a program to print the smallest possible number R by rearranging the same set of digits. Ze If the given number N is already the smallest possible number with those set of digits, print out the same number. Read the input from STDIN and print the output to STDOUT. Do not write arbitrary strings while reading the input or while Constraints N>9 Input Format: The input contains an integer N. Output Format: The output contains R. Sample Input1: 231 Sample Output: 123 Explanation: Given number Nis 231. The digits of N are 2,3 and 1. After all the possible combinations of the digits, the numbers formed are: 321, 312, 3 The smallest number Ramong all is 123. Sample Input2 2304 Sample Output2 2034 For any given number N, write a program to print the smallest possible number R by rearranging the same set of digite If the given number N is already the smallest possible number with those set of digits, print out the same number. Read the input from STDIN and print the output to STDOUT. Do not write arbitrary strings while reading the input or w Constraints N>9 Input Format: The input contains an integer N. Output Format: The output contains R. Sample Input: 231 Sample Output: 123 Explanation: Given number Nis 231. The digits of N are 2,3 and 1. After all the possible combinations of the digits, the numbers formed are: 321,37 The smallest number Ramong all is 123. Sample Input2: 2304 Sample Output2: 2034 given number N, write a program to print the smallest possible number R by rearranging the same set of digits. Zero cannot be the leadin en number N is already the smallest possible number with those set of digits, print out the same number. input from STDIN and print the output to STDOUT. Do not write arbitrary strings while reading the input or while printing, as these con eat: ontains an integer N. nat: contains R. uti: Nis 231 are 2, 3 and 1. After all the possible combinations of the digits, the numbers formed are: 321, 312, 213, 231, 123, 132. umber Ramong all is 123

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!