human
Find the point where maximum intervals overlap | Program to find maximum guest at any time in a party.
Sort arrival and exit arrays.
guests_in indicates number of guests at a time.
Similar to merge in merge sort to process all events in sorted order.
If next event in sorted order is arrival , increment count of guests.
Update max_guests if needed.
increment index of arrival array.
If event is exit , decrement count.
of guests ..
Driver Code"
How can the above be solved in Python?
 ... What is a code to find the point where maximum intervals overlap and the other steps required?
assistant
#Here is code to find the point where maximum intervals overlap and the other steps required.
 def findMaxGuests ( arrl , exit , n ) :
	arrl . sort ( ) ;
	exit . sort ( ) ;
	guests_in = 1 ;
	max_guests = 1 ;
	time = arrl [ 0 ] ;
	i = 1 ;
	j = 0 ;
	while ( i < n and j < n ) :
		if ( arrl [ i ] <= exit [ j ] ) :
			guests_in = guests_in + 1 ;
			if ( guests_in > max_guests ) :
				max_guests = guests_in ;
				time = arrl [ i ] ;
			i = i + 1 ;
		else :
			guests_in = guests_in - 1 ;
			j = j + 1 ;
	print ( " Maximum ▁ Number ▁ of ▁ Guests ▁ = " , max_guests , " at ▁ time " , time )
arrl = [ 1 , 2 , 10 , 5 , 5 ] ;
exit = [ 4 , 5 , 12 , 9 , 12 ] ;
n = len ( arrl ) ;
findMaxGuests ( arrl , exit , n ) ;