human
Give me a code to how to check if two given sets are disjoint given the following:
How to check if two given sets are disjoint ? | Returns true if set1 [ ] and set2 [ ] are disjoint , else false.
Sort the given two sets.
Check for same elements using merge like process.
if set1 [ i ] == set2 [ j ].
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to how to check if two given sets are disjoint .
 def areDisjoint ( set1 , set2 , m , n ) :
	set1 . sort ( )
	set2 . sort ( )
	i = 0 ; j = 0
	while ( i < m and j < n ) :
		if ( set1 [ i ] < set2 [ j ] ) :
			i += 1
		elif ( set2 [ j ] < set1 [ i ] ) :
			j += 1
		else :
			return False
	return True
set1 = [ 12 , 34 , 11 , 9 , 3 ]
set2 = [ 7 , 2 , 1 , 5 ]
m = len ( set1 )
n = len ( set2 )
print ( " Yes " ) if areDisjoint ( set1 , set2 , m , n ) else print ( " No " )