human
Maximum time in HH : MM : SS format that can be represented by given six digits | Function to return the maximum possible time in 24 - Hours format that can be represented by array elements.
Stores the frequency of the array elements.
Maximum possible time.
Iterate to minimum possible time.
Conditions to reduce the the time iteratively.
If all required digits are present in the Map.
Retrieve Original Count.
If seconds is reduced to 0.
If minutes is reduced to 0.
Driver Code"
Solution in Python:

Give me a code to maximum time in HH : MM : SS format that can be represented by given six digits and the other steps required?
assistant
#Here is code to maximum time in HH : MM : SS format that can be represented by given six digits and the other steps required.
 def largestTimeFromDigits ( A ) :
	mp1 = { }
	mp2 = { }
	for x in A :
		mp1 [ x ] = mp1 . get ( x , 0 ) + 1
	mp2 = mp1 . copy ( )
	hr = 23
	m = 59
	s = 59
	while ( hr >= 0 ) :
		h0 = hr // 10
		h1 = hr % 10
		m0 = m // 10
		m1 = m % 10
		s0 = s // 10
		s1 = s % 10
		p = 0
		arr = [ h0 , h1 , m0 , m1 , s0 , s1 ]
		for it in arr :
			if ( it in mp1 and mp1 . get ( it ) > 0 ) :
				mp1 [ it ] = mp1 . get ( it ) - 1
			else :
				p = 1
		if ( p == 0 ) :
			s = " "
			s = ( str ( h0 ) + str ( h1 ) )
			s += ( ' : ' + str ( m0 ) + str ( m1 ) )
			s += ( ' : ' + str ( s0 ) + str ( s1 ) )
			return s
		mp1 = mp2 . copy ( )
		if ( s == 0 ) :
			s = 59
			m -= 1
		elif ( m < 0 ) :
			m = 59
			hr -= 1
		if ( s > 0 ) :
			s -= 1
	return " - 1"
if __name__ == ' _ _ main _ _ ' :
	v = [ 0 , 2 , 1 , 9 , 3 , 2 ]
	print ( largestTimeFromDigits ( v ) )