LeetCode - Parentheses 总结

DFS

22. Generate Parentheses

301. Remove Invalid Parentheses (BFS)

Stack

20. Valid Parentheses

32. Longest Valid Parentheses (also dp)

tip:

1. stack里面存'('的index instead of the character itself

2. validity <- use the stack

divide and conquer

241. Different Ways to Add Parentheses

string

856. Score of Parentheses

Notes:

1.如果只存在一种parentheses可以直接用left and right count来表示

猜你喜欢

转载自blog.csdn.net/real_lisa/article/details/82963148