human
Job Scheduling with two jobs allowed at a time | Python3 program to check if all jobs can be scheduled if two jobs are allowed at a time ..
making a pair of starting and ending time of job.
sorting according to starting time of job.
starting first and second job simultaneously.
Checking if starting time of next new job is greater than ending time of currently scheduled first job.
Checking if starting time of next new job is greater than ending time of ocurrently scheduled second job.
Driver Code.
startin = [ 1 , 2 , 4 ] starting time of jobs endin = [ 2 , 3 , 5 ] ending times of jobs"
Solution in Python:
assistant
#Here is code to job Scheduling with two jobs allowed at a time and the other steps required.
 def checkJobs ( startin , endin , n ) :
	a = [ ]
	for i in range ( 0 , n ) :
		a . append ( [ startin [ i ] , endin [ i ] ] )
	a . sort ( )
	tv1 = a [ 0 ] [ 1 ]
	tv2 = a [ 1 ] [ 1 ]
	for i in range ( 2 , n ) :
		if ( a [ i ] [ 0 ] >= tv1 ) :
			tv1 = tv2
			tv2 = a [ i ] [ 1 ]
		elif ( a [ i ] [ 0 ] >= tv2 ) :
			tv2 = a [ i ] [ 1 ]
		else :
			return 0
	return 1
if __name__ == ' _ _ main _ _ ' :
	n = 3
	print ( checkJobs ( startin , endin , n ) )