Correct bracket sequences can be defined recursively as follows:
- The empty string "" is a correct sequence.
- If "X" and "Y" are correct sequences, then "XY" (the concatenation of X and Y) is a correct sequence.
- If "X" is a correct sequence, then "(X)" and "[X]" are also correct sequences.
- Each correct bracket sequence can be derived using the above rules.
Examples of correct bracket sequences include "", "()", "()", "(())", and "([[()]])".
You are given a String s that only contains the characters '(', ')', '[', and ']'.
We want to erase some subset of characters of s (possibly none of them, but not all of them).
Moreover, we want to do it in such a way that the resulting string will be a correct non-empty bracket sequence.
Compute and return the number of ways in which this can be done.