So I have an array full of brackets, for example :
1) (()())())((())(())
2) ()((()()))
Any open bracket ( '(' ) should also be closed by another one (')')
So for example 1) ->
(()())())((())(()) -> (....)..)((..)(..) -> ())(()() -> .)(.. , so the answer is no because from here we can see that not all of the brackets are balanced
For example 2) ->
()((()())) -> .((..)) -> (()) -> (..) -> () -> .. , so here the answer is yes because all brackets are balanced. In this case, I would also like to print the positions of all couples of brackets that are balanced, for example :
1,2 & 5,6 & 7,8 & 3,10 & 4,9
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~