Number of balanced bracket subsequence of length 2 and 4 - GeeksforGeeks
Given a bracket sequence of even length. The task is to find how many ways are there to make balanced bracket subsequences from the given sequence of length 2 and 4.
The sequence () is a bracket sequence of length 2. A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.
Note: "1" represent opening bracket and "2" represents closing bracket
Examples:
Input: 1 2 1 1 2 2 Output: 14 Input: 1 2 1 2 Output: 4
Read full article from Number of balanced bracket subsequence of length 2 and 4 - GeeksforGeeks
No comments:
Post a Comment