text: Check the wave form * If arr [ 1 ] is greater than left * and right . Same pattern will be * followed by whole elements , else * reverse pattern will be followed by array elements
code: if ( arr [ 1 ] > arr [ 0 ] && arr [ 1 ] > arr [ 2 ] ) { for ( int i = 1 ; i < n - 1 ; i += 2 ) { if ( arr [ i ] > arr [ i - 1 ] && arr [ i ] > arr [ i + 1 ] ) { result = true ; } else { result = false ; break ; } }