Declare DP Array
int dp [ N + 2 ] [ N + 2 ] ; memset ( dp , 0 , sizeof ( dp ) ) ; for ( int length = 1 ; length < N + 1 ; length ++ ) { for ( int left = 1 ; left < N - length + 2 ; left ++ ) { int right = left + length - 1 ;