human
Find the distance between two person after reconstruction of queue | Function to find the correct order and then return the distance between the two persons.
Make pair of both height & infront and insert to vector.
Sort the vector in ascending order.
Find the correct place for every person.
Insert into position vector according to infront value.
Driver code"
How can the above be solved in Python?
 Can you provide a code to find the distance between two person after reconstruction of queue and the other steps required?
assistant
#Here is code to find the distance between two person after reconstruction of queue and the other steps required.
 def getDistance ( arr , n , a , b ) :
	vp = [ ]
	for i in range ( n ) :
		vp . append ( [ arr [ i ] [ 0 ] , arr [ i ] [ 1 ] ] )
	vp = sorted ( vp )
	pos = [ 0 for i in range ( n ) ]
	for i in range ( len ( vp ) ) :
		height = vp [ i ] [ 0 ]
		k = vp [ i ] [ 1 ]
		pos [ k ] = height
	first = - 1
	second = - 1
	for i in range ( n ) :
		if ( pos [ i ] == a ) :
			first = i
		if ( pos [ i ] == b ) :
			second = i
	return abs ( first - second )
arr = [ [ 5 , 0 ] , [ 3 , 0 ] , [ 2 , 0 ] , [ 6 , 4 ] , [ 1 , 0 ] , [ 4 , 3 ] ]
n = len ( arr )
a = 6
b = 5
print ( getDistance ( arr , n , a , b ) )