human
Check if array contains contiguous integers with duplicates allowed | Function to check whether the array contains a set of contiguous integers.
Storing elements of ' arr [ ] ' in a hash table 'us  .
As arr [ 0 ] is present in 'us  .
Starting with previous smaller element of arr [ 0 ].
If ' curr _ ele ' is present in 'us  .
Increment count.
Update 'curr_ele".
Starting with next greater element of arr [ 0 ].
If ' curr _ ele ' is present in 'us  .
Increment count.
Update 'curr_ele".
Returns true if array contains a set of contiguous integers else returns false.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to check if array contains contiguous integers with duplicates allowed and the other steps required.
 def areElementsContiguous ( arr ) :
	us = set ( )
	for i in arr : us . add ( i )
	count = 1
	curr_ele = arr [ 0 ] - 1
	while curr_ele in us :
		count += 1
		curr_ele -= 1
	curr_ele = arr [ 0 ] + 1
	while curr_ele in us :
		count += 1
		curr_ele += 1
	return ( count == len ( us ) )
arr = [ 5 , 2 , 3 , 6 , 4 , 4 , 6 , 6 ]
if areElementsContiguous ( arr ) : print ( " Yes " )
else : print ( " No " )