You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So first I made the RBS with minimmum cost by putting closing bracket as soon as we get a opening bracket before it, i.e., closing bracket as early as
6
+
possible(greedy appraoch). After getting corect bracket sequence I put the indexes of '(' in vector o and indexes of ')' in vector c in order they occur. Both
7
+
vector must contain n/2 elements and now for final answer I simply added the difference of each element in o and c at same index to ans to calculate cost
8
+
which was initially zero and then printed the ans.
0 commit comments