human
Give me a code to find the largest interval that contains exactly one of the given N integers given the following:
Find the largest interval that contains exactly one of the given N integers . | Function to return the maximum size of the required interval.
Insert the borders for array.
Sort the elements in ascending order.
To store the maximum size.
To store the range [ L , R ] such that only v [ i ] lies within the range.
Total integers in the range.
Driver code"
Solution in Python:
assistant
#Here is code to find the largest interval that contains exactly one of the given N integers .
 def maxSize ( v , n ) :
	v . append ( 0 )
	v . append ( 100001 )
	n += 2
	v = sorted ( v )
	mx = 0
	for i in range ( 1 , n - 1 ) :
		L = v [ i - 1 ] + 1
		R = v [ i + 1 ] - 1
		cnt = R - L + 1
		mx = max ( mx , cnt )
	return mx
v = [ 200 , 10 , 5 ]
n = len ( v )
print ( maxSize ( v , n ) )