一道facebook面试题

原帖地址:mitbbs

remove minimum number of left and right brackets and return the string with
valid bracket pairs. given (a))()), should return (a)(), or (a()); given )()
()), should return either ()() or (()); given ()((9()), should return either
()(9()) or ()((9)).

当时想用longest valid parentheses思路套,结果里头加了字符关系没理清楚,回来
想了想,一个stack就可以很容易解决了。