human
Find original sequence from Array containing the sequence merged many times in order | Function that returns the restored permutation.
List to store the result.
Map to mark the elements which are taken in result.
Checking if the element is coming first time.
Push in result vector.
Mark it in the map.
Return the answer.
Function to print the result.
Driver code.
Given array.
Function call"
How can the above be solved in Python?
assistant
#Here is code to find original sequence from Array containing the sequence merged many times in order and the other steps required.
 def restore ( arr , N ) :
	result = [ ]
	mp = { }
	for i in range ( N ) :
		if not arr [ i ] in mp :
			result . append ( arr [ i ] )
			mp [ arr [ i ] ] = 1
	return result
def print_result ( result ) :
	for i in range ( len ( result ) ) :
		print ( result [ i ] , end = " ▁ " )
def main ( ) :
	arr = [ 1 , 13 , 1 , 24 , 13 , 24 , 2 , 2 ]
	N = len ( arr )
	print_result ( restore ( arr , N ) )
main ( )