# Find Leaves of Binary Tree

<https://shuati.gitbook.io/crack-lintcode/~/edit/drafts/-LML4yotQUd1ltlwtPxk/binary-tree/find-leaves-of-binary-tree-07-25>

time o(n),space o(n)

mimic the leave level as index,

when we recursively call dfs to the leave, we get the return is 0, if now res.size() <= index, which means we neet to create a new list, otherwise , the corresponding index list is already in the res

return index+1 to the upper level


---

# Agent Instructions: 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://shuati.gitbook.io/crack-lintcode/linkedin/find-leaves-of-binary-tree.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.
