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

@@ -22,6 +22,22 @@ sidebar:
- `1 <= n <= 20`
- `-1000 <= matrix[i][j] <= 1000`
## Approach
```mermaid
flowchart TD
S(["rotate(matrix)"]) --> N["n = len(matrix)"]
N --> F{"more r in range(n)?"}
F -- yes --> G{"more c in range(r + 1, n)?"}
G -- yes --> T["swap matrix[r][c] and matrix[c][r] — transpose across the diagonal"]
T --> G
G -- no --> F
F -- no --> H{"more r in range(n)?"}
H -- yes --> R["matrix[r].reverse() — transpose then mirror is a clockwise turn"]
R --> H
H -- no --> E(["return None — rotated in place"])
```
## Solution
```py
@@ -35,3 +51,7 @@ class Solution:
for r in range(n):
matrix[r].reverse()
```
## Explanation
<YouTube id="fMSJSS7eO1w" title="Rotate Image - Matrix - Leetcode 48" />