CountWays function
public static int countWays ( int N , String S ) { int dp [ ] [ ] [ ] = new int [ N + 1 ] [ N + 1 ] [ 2 ] ; for ( int row [ ] [ ] : dp ) for ( int col [ ] : row ) Arrays . fill ( col , - 1 ) ; return parenthesis_count ( S , 0 , N - 1 , 1 , dp ) ; }