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 , prvar Yes ; Driver Code
function check ( arr , n ) { for ( var i = 1 ; i < n ; i ++ ) { if ( arr [ i - 1 ] >= ( i - 1 ) ) { var p = arr [ i - 1 ] - ( i - 1 ) ; arr [ i ] += p ; arr [ i - 1 ] -= p ; } } for ( var i = 1 ; i < n ; i ++ ) { if ( arr [ i ] <= arr [ i - 1 ] ) { document . write ( " " ) ; return ; } } document . write ( " " ) ; } var arr = [ 1 , 5 , 2 , 7 , 6 ] ; var N = arr . length ; check ( arr , N ) ;