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

@@ -30,6 +30,21 @@ sidebar:
- `p != q`
- p and q will exist in the tree.
## Approach
```mermaid
flowchart TD
S(["lowestCommonAncestor(root, p, q)"]) --> B{"not root?"}
B -- yes --> N(["return None"])
B -- no --> M{"root == p or root == q?"}
M -- yes --> R(["return root — a node is its own ancestor"])
M -- no --> L["l = self.lowestCommonAncestor(root.left, p, q)"]
L --> Q["r = self.lowestCommonAncestor(root.right, p, q)"]
Q --> D{"l and r?"}
D -- yes --> A(["return root — p and q were found on different sides"])
D -- no --> E(["return l or r — pass up whichever side found something"])
```
## Solution
```py