C++ program to print the maximum possible time using six of nine given single digits
Given a set of nine single digits ((not necessarily distinct) say 0,0,1,3,4,6,7,8,9. It is possible to form many distinct times in a 12 hour time format HH:MM:SS, such as 10:36:40 or 01:39:46 by using each of the digits only once. The objective is to find the maximum possible valid time (00:00:01 to 12:00:00) that can be formed using some six of the nine digits exactly once. In this case, it is 10:49:38.
Example:
1) Set={0,1,3,4,2,1,5,8,0}
It will print-: 11:58:43
2) Set={0,9,6,9,7,8,9,6,3}
It will print-: Impossible Operation!
Consider the program:
Output
need an explanation for this answer? contact us directly to get an explanation for this answer