r*u
1 楼
Develop an algorithm to find out all valid combinations of n brackets. Like
for n =3 possible combinations can be ((())) or ()()() or (()()) and so on
这个就是用个stack放'(', 然后有个output array, 如果stack不空,output这个位置
可以放'('或),如果stack空就只能放'('还有遇到(。push it to stack,遇到),pop
。然后递归,对吧。我code了一下怎么都不对,有没有谁给个code我能参考一下,谢谢
!
for n =3 possible combinations can be ((())) or ()()() or (()()) and so on
这个就是用个stack放'(', 然后有个output array, 如果stack不空,output这个位置
可以放'('或),如果stack空就只能放'('还有遇到(。push it to stack,遇到),pop
。然后递归,对吧。我code了一下怎么都不对,有没有谁给个code我能参考一下,谢谢
!