Make an array strictly increasing by repeatedly subtracting and adding arr [ i | Function to check if an array can be made strictly increasing ; Traverse the given array arr [ ] ; Update the value of p , arr [ i ] , and arr [ i - 1 ] ; Traverse the given array ; Check if the array arr [ ] is strictly increasing or not ; Otherwise , array is increasing order , prYes ; Driver Code
def check ( arr , n ) : NEW_LINE INDENT for i in range ( 1 , n ) : NEW_LINE INDENT if ( arr [ i - 1 ] >= ( i - 1 ) ) : NEW_LINE INDENT p = arr [ i - 1 ] - ( i - 1 ) NEW_LINE arr [ i ] += p NEW_LINE arr [ i - 1 ] -= p NEW_LINE DEDENT DEDENT for i in range ( 1 , n ) : NEW_LINE INDENT if ( arr [ i ] <= arr [ i - 1 ] ) : NEW_LINE INDENT print ( " No " ) NEW_LINE return NEW_LINE DEDENT DEDENT print ( " Yes " ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 1 , 5 , 2 , 7 , 6 ] NEW_LINE N = len ( arr ) NEW_LINE check ( arr , N ) NEW_LINE DEDENT