> 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/0797_all_paths_from_source_to_target/slt.md).

# Solution1 DFS

* 时间复杂度 $O(n \* 2^n)$

  &#x20; 共有 n 个节点，每个节点有选和不选两种决策，共 $2^n$。对于每个方案最坏情况需要 O(n) 的复杂度进行拷贝并添加到结果集。
* 空间复杂度 $O(n \* 2^n)$

  &#x20; 最多有 2^n 种方案，每个方案最多有 n 个元素
