human
Check if all subarrays contains at least one unique element | ''Function to check if all subarrays have at least one unique element.
'' Generate all subarray.
' ' ▁ Store ▁ frequency ▁ of ▁ ▁ subarray ' s elements.
'' Traverse the array over  the range [i, N].
'' Update frequency of  current subarray in map.
'' Increment count.
'' Decrement count.
'' If all subarrays have at  least 1 unique element.
''Driver Code.
'' Given array arr[].
'' Function Call"
How can the above be solved in Python?
 Write me a code to check if all subarrays contains at least one unique element and the other steps required?
assistant
#Here is code to check if all subarrays contains at least one unique element and the other steps required.
 def check ( arr , n ) :
	for i in range ( n ) :
		hm = { }
		count = 0
		for j in range ( i , n ) :
			hm [ arr [ j ] ] = hm . get ( arr [ j ] , 0 ) + 1
			if ( hm [ arr [ j ] ] == 1 ) :
				count += 1
			if ( hm [ arr [ j ] ] == 2 ) :
				count -= 1
			if ( count == 0 ) :
				return " No "
	return " Yes "
if __name__ == ' _ _ main _ _ ' :
	arr = [ 1 , 2 , 1 ]
	N = len ( arr )
	print ( check ( arr , N ) )