Brackets all over challenge

I’m unable to understand what has to be done Please explain in with some examples.

Hi abhinav,share the question link here.

https://online.codingblocks.com/player/14822/content/5222?s=3103

Hey Abhinav,
you can solve this problem using dynamic programming:

First calculate dp[i, j] i.e. how many sequences of brackets of length i has balance j and intermediate balance never goes below zero (They form a prefix of a valid sequence of brackets).

For the given sequence of length n calculate the resulting balance a and the minimum balance b.

Try the length of the sequence added at the beginning c and its balance d. If - b ≤ d then add dp[c, d] × dp[m - n - c, d + a] to the answer.