> 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/0020_valid_parentheses/slt.md).

# slt

不管哪种方法，如果 长度是奇数，直接返回false

## 思路1 stack 直接把当前左括号对应的右括号入栈

注意括号交错要返回False

一种映射方法是只把右括号push入栈

## 思路2 stack 把左括号入栈，遇到对应的右括号则弹出

* 时间复杂度 O(n)
* 空间复杂度 O(n)

这是最容易想到的方法


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://851958789.gitbook.io/notes/0020_valid_parentheses/slt.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
