human
Check if an Array can be Sorted by picking only the corner Array elements | Function to check if an array can be sorted using given operations.
If sequence becomes increasing after an already non - decreasing to non - increasing pattern.
If a decreasing pattern is observed.
Driver Code"
Solution in Python:
 ... Can you provide a code to check if an Array can be Sorted by picking only the corner Array elements and the other steps required?
assistant
#Here is code to check if an Array can be Sorted by picking only the corner Array elements and the other steps required.
 def check ( arr , n ) :
	g = 0
	for i in range ( 1 , n ) :
		if ( arr [ i ] - arr [ i - 1 ] > 0 and g == 1 ) :
			return False
		if ( arr [ i ] - arr [ i ] < 0 ) :
			g = 1
	return True
arr = [ 2 , 3 , 4 , 10 , 4 , 3 , 1 ]
n = len ( arr )
if ( check ( arr , n ) == True ) :
	print ( " Yes " )
else :
	print ( " No " )