Check if array can be converted into strictly decreasing sequence | Java implementation to check that array can be converted into a 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
class GFG { static boolean check ( int [ ] arr , int n ) { boolean flag = true ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < n - i ) { flag = false ; } } if ( flag ) { return true ; } else { return false ; } } public static void main ( String [ ] args ) { int arr1 [ ] = { 11 , 11 , 11 , 11 } ; int n1 = arr1 . length ; if ( check ( arr1 , n1 ) ) { System . out . print ( " Yes " + "NEW_LINE"); } else { System . out . print ( " No " + "NEW_LINE"); } } }