||I tried solving BRCKTS using Binary Indexed Tree. The approach as highlighted in some forums -
1. The frequency at an index is +1 or -1 for an opening or a closing bracket respectively.
2. Level of imbrication at an index is the cumulative frequency.
3. For checking, find the minimum level of imbrication. And the level of imbrication for the final index. If both 0, then the present expression is correct, else it is incorrect.
I am unable to figure out a way for maintain the minimum level of imbrication in O(log n). Can someone suggest a way for finding the minimum ?