Check if array can be converted into strictly decreasing sequence | Function to check that array can be converted into a strictly decreasing sequence ; Loop to check that each element is greater than the ( N - index ) ; If element is less than ( N - index ) ; If array can be converted ; Driver Code ; Function calling
function check ( arr , n ) { var flag = true ; for ( let i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < n - i ) { flag = false ; } } if ( flag ) { return true ; } else { return false ; } } let arr1 = [ 11 , 11 , 11 , 11 ] ; let n1 = arr1 . length ; if ( check ( arr1 , n1 ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }