human
What is a code to check if removal of a subsequence of non and the other steps required given the following:
Check if removal of a subsequence of non | Function to check if it is possible to sort the array or not.
Stores the index if there are two consecutive 1 's in the array.
Traverse the given array.
Check adjacent same elements having values 1 s.
If there are no two consecutive 1 s , then always remove all the 1 s from array & make it sorted.
If two consecutive 0 ' s ▁ are ▁ ▁ present ▁ after ▁ two ▁ consecutive ▁ ▁ 1' s then array can 't be sorted.
Otherwise , print Yes.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to check if removal of a subsequence of non and the other steps required.
 def isPossibleToSort ( arr , N ) :
	idx = - 1
	for i in range ( 1 , N ) :
		if ( arr [ i ] == 1 and arr [ i - 1 ] == 1 ) :
			idx = i
			break
	if ( idx == - 1 ) :
		print ( " YES " )
		return
	for i in range ( idx + 1 , N , 1 ) :
		if ( arr [ i ] == 0 and arr [ i - 1 ] == 0 ) :
			print ( " NO " )
			return
	print ( " YES " )
if __name__ == ' _ _ main _ _ ' :
	arr = [ 1 , 0 , 1 , 0 , 1 , 1 , 0 ]
	N = len ( arr )
	isPossibleToSort ( arr , N )