static void constructDp ( int dp [ ] [ ] , String str ) {
  int l = str . length ( ) ;
  int [ ] [ ] isPalin = new int [ l + 1 ] [ l + 1 ] ;
  for ( int i = 0 ;
  i <= l ;
  i ++ ) {
    for ( int j = 0 ;
    j <= l ;
    j ++ ) {
      isPalin [ i ] [ j ] = dp [ i ] [ j ] = 0 ;
    }
  }
  for ( int i = l - 1 ;
  i >= 0 ;
  i -- ) {
    isPalin [ i ] [ i ] = 1 ;
    dp [ i ] [ i ] = 1 ;
    for ( int j = i + 1 ;
    j < l ;
    j ++ ) {
      isPalin [ i ] [ j ] = ( str . charAt ( i ) == str . charAt ( j ) && ( i + 1 > j - 1 || ( isPalin [ i + 1 ] [ j - 1 ] ) != 0 ) ) ? 1 : 0 ;
      dp [ i ] [ j ] = dp [ i ] [ j - 1 ] + dp [ i + 1 ] [ j ] - dp [ i + 1 ] [ j - 1 ] + isPalin [ i ] [ j ] ;
    }
  }
}

static void constructDp ( int dp [ ] [ ] , String str ) { int l = str . length ( ) ; int [ ] [ ] isPalin = new int [ l + 1 ] [ l + 1 ] ; for ( int i = 0 ; i <= l ; i ++ ) { for ( int j = 0 ; j <= l ; j ++ ) { isPalin [ i ] [ j ] = dp [ i ] [ j ] = 0 ; } } for ( int i = l - 1 ; i >= 0 ; i -- ) { isPalin [ i ] [ i ] = 1 ; dp [ i ] [ i ] = 1 ; for ( int j = i + 1 ; j < l ; j ++ ) { isPalin [ i ] [ j ] = ( str . charAt ( i ) == str . charAt ( j ) && ( i + 1 > j - 1 || ( isPalin [ i + 1 ] [ j - 1 ] ) != 0 ) ) ? 1 : 0 ; dp [ i ] [ j ] = dp [ i ] [ j - 1 ] + dp [ i + 1 ] [ j ] - dp [ i + 1 ] [ j - 1 ] + isPalin [ i ] [ j ] ; } } }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (type_identifier) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (binary_expression left: (identifier) right: (decimal_integer_literal))) dimensions: (dimensions_expr (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (decimal_integer_literal)))))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (decimal_integer_literal))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (ternary_expression condition: (parenthesized_expression (binary_expression left: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) right: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (binary_expression left: (parenthesized_expression (array_access array: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (decimal_integer_literal)))))) consequence: (decimal_integer_literal) alternative: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (binary_expression left: (binary_expression left: (binary_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (array_access array: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) index: (identifier))) right: (array_access array: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)))))))))))