> For the complete documentation index, see [llms.txt](https://851958789.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://851958789.gitbook.io/notes/0301_remove_invalid_parentheses/slt.md).

# Solution1 DFS

1. traverse s, get matched left and right parentheses count
2. dfs, delete corresponding left and right parenthese, and see if is valid
