So i am using the dp state of dp[a][b] this state is unique as for each index i, the sum a+b changes i.e if at index i the value are a = 3, b = 5 so dp[3][5] is the state.

now at any other index say i+1, state of a=3 and b=5 is not possible because we when move over an index the count of a or b has to decrease.

But the code does not pass all the testcases:

Code Link: