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 ] = 1000000000 NEW_LINE arr [ MAX - 1 ] = - 1000000000 NEW_LINE dp = [ [ [ - 1 for i in range ( MAX ) ] for i in range ( MAX ) ] for i in range ( MAX ) ] NEW_LINE return countMin ( arr , dp , n , MAX - 2 , MAX - 1 , 0 ) NEW_LINE