Store palindromes of size 2
for ( i = 0 ; i < s . length ( ) - 1 ; i ++ ) { if ( s . charAt ( i ) == s . charAt ( i + 1 ) ) { dp [ i ] [ i + 1 ] = 1 ; m . put ( s . substring ( i , i + 2 ) , true ) ; }