human
Split Array into min number of subsets with difference between each pair greater than 1 | Function to Split the array into minimum number of subsets with difference strictly > 1.
Sort the array.
Traverse through the sorted array.
Check the pairs of elements with difference 1.
If we find even a single pair with difference equal to 1 , then 2 partitions else only 1 partition.
Print the count of partitions.
Driver Code.
Given array.
Size of the array.
Function call"
Solution in Python:
 ... Can you provide a code to split Array into min number of subsets with difference between each pair greater than 1 and the other steps required?
assistant
#Here is code to split Array into min number of subsets with difference between each pair greater than 1 and the other steps required.
 def split ( arr , n ) :
	arr . sort ( )
	count = 1
	for i in range ( 1 , n ) :
		if ( arr [ i ] - arr [ i - 1 ] == 1 ) :
			count = 2
			break
	print ( count )
if __name__ == ' _ _ main _ _ ' :
	arr = [ 2 , 4 , 6 ]
	n = len ( arr )
	split ( arr , n )