Why this Code ,which finds Minimum Cost To Make String Valid not works properly for larger test cases?
A string ‘STR’ containing either ‘{’ or ‘}’. ‘STR’ is called valid if all the brackets are balanced. Formally for each opening bracket, there must be a closing bracket right to it.