Https://ide.codingblocks.com/s/279261

lol, code gets accepted without memoisation… but i need to memoise it , its giving 0 all the time , please check why…my logic is i have created a 3d array dp[current index][ open count][close count]

You have declared second and third state size as n+1, but the number of opening brackets can be more than that in recursion.