【100 points】【Maximum time】

topic description

Given an array with 6 integers in it, find the maximum 24-bit time that the array can represent, output this time, and output invalid if it cannot be represented.

enter description

The input is an array of integers with six integers in the array.

The length of the input integer array is 6, no need to consider other lengths, the element value is 0 or a positive integer, and each of the 6 numbers can only be used once.

output description

The output is a time in hexadecimal format, or the string "invalid".

Remark:

The output time format is xxxxx.

Example 1 The input and output examples are only for debugging, and the background judgment data generally does not include examples

enter

[0,2,3,0,5,6]

output

23:56:00

train of thought

Ideas:

  1. First, we need to get an array of 6 integers from the input, representing the set of input numbers.

  2. Next, we need to perform a full permutation of this array to get all the different permutations and combinations. This can be achieved using the depth-first search (DFS) algorithm. The basic idea of ​​DFS is to start from the first element of the array, and exchange each element with other unused elements in turn to form different permutations and combinations.

  3. When doing DFS, we need to define a helper function dfs()to do the recursive search. in the search

Guess you like

Origin blog.csdn.net/weixin_54707168/article/details/131979173