Adding two number at the end of array , so that increasing and decreasing sequence can be made . MAX - 2 index is assigned INT_MAX for decreasing sequence because / next number of sequence must be less than it . Similarly , for Increasing sequence INT_MIN is assigned to MAX - 1 index .
arr [ MAX - 2 ] = INT_MAX ; arr [ MAX - 1 ] = INT_MIN ; int dp [ MAX ] [ MAX ] [ MAX ] ; memset ( dp , -1 , sizeof dp ) ; return countMin ( arr , dp , n , MAX - 2 , MAX - 1 , 0 ) ; }