docs(docs): add Approach diagrams and Explanation sections to LeetCode problem documentation

This commit is contained in:
Prad Nukala committed 2026-09-21 15:53:21 -04:00
1 parent b8c779903f
commit 23eb71d387
19 files changed
+439

No files matched your search

@@ -25,6 +25,17 @@ sidebar:
- The number of nodes in the tree is in the range [0, 100].
- `-100 <= Node.val <= 100`
## Approach
```mermaid
flowchart TD
S(["invertTree(root)"]) --> B{"root is None?"}
B -- yes --> Z(["return None"])
B -- no --> L["left = invertTree(root.left), right = invertTree(root.right) — both subtrees are already inverted"]
L --> X["root.left = right, root.right = left"]
X --> E(["return root"])
```
## Solution
```py
@@ -47,3 +58,7 @@ class Solution:
return root
```
## Explanation
<YouTube id="OnSn2XEQ4MY" title="Invert Binary Tree - Depth First Search - Leetcode 226" />