If n is odd , string cannot be balanced
if ( n % 2 == 1 ) return 0 ; let dp = new Array ( MAX ) ; for ( let i = 0 ; i < MAX ; i ++ ) { dp [ i ] = new Array ( MAX ) ; for ( let j = 0 ; j < MAX ; j ++ ) dp [ i ] [ j ] = - 1 ; } return countRec ( 0 , n - 1 , dp , st ) ; }