Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
russhustle committed Feb 22, 2025
1 parent d6cc10d commit 064cc78
Show file tree
Hide file tree
Showing 33 changed files with 2,478 additions and 301 deletions.
12 changes: 3 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ search:

clean:
find . -name ".DS_Store" -type f -delete
# delete __pycache__ folders
find . -name "__pycache__" -type d -exec rm -r {} +
find . -name "output" -type d -exec rm -r {} +

push:
git add .
Expand All @@ -18,11 +18,5 @@ push:
sync:
poetry run python utils/sync.py

pre-commit:
poetry run pre-commit run --all-files

generate:
poetry run python utils/sync.py
poetry run python utils/integrate.py
poetry run pre-commit run --all-files
poetry run pre-commit run --all-files
format:
poetry run pre-commit run --all-files || $(MAKE) format
2 changes: 2 additions & 0 deletions docs/blind75/advanced_graphs.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ comments: True

## 269. Alien Dictionary

- Return the correct order of characters in the alien language.

=== "Python"

```python
Expand Down
30 changes: 20 additions & 10 deletions docs/blind75/graphs.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@ comments: True
- Return true if it is possible to finish all courses, otherwise return false.
- Dependency relationships imply the topological sort algorithm.
- Cycle detection
- Topological Sort
- DAG (Directed Acyclic Graph)
- Time complexity: O(V+E)
- Space complexity: O(V+E)
- Prerequisites: Indegree (Look at the problem [1557. Minimum Number of Vertices to Reach All Nodes](#1557-minimum-number-of-vertices-to-reach-all-nodes))
- Indegree: Number of incoming edges to a vertex
- Applications: task scheduling, course scheduling, build systems, dependency resolution, compiler optimization, etc.

![ts1](../assets/graph_ts1.png){width=300px}

![ts2](../assets/graph_ts2.png){width=300px}

Course to prerequisites mapping

```mermaid
flowchart LR
Expand All @@ -95,6 +108,7 @@ flowchart LR
1((1)) --> 4((4))
```

Prerequisites to course mapping

```mermaid
flowchart LR
Expand Down Expand Up @@ -128,8 +142,7 @@ Initialize
| in-degree | 2 | 2 | 0 | 1 | 0 |

- queue: `[2, 4]`

Pop `2` from the queue
- pop `2` from the queue

```mermaid
flowchart LR
Expand All @@ -144,8 +157,7 @@ flowchart LR
| in-degree | 1 | 2 | 0 | 1 | 0 |

- queue: `[4]`

Pop `4` from the queue
- pop `4` from the queue

```mermaid
flowchart LR
Expand All @@ -158,8 +170,7 @@ flowchart LR
| in-degree | 1 | 1 | 0 | 0 | 0 |

- queue: `[3]`

Pop `3` from the queue
- pop `3` from the queue

```mermaid
flowchart LR
Expand All @@ -171,8 +182,7 @@ flowchart LR
| in-degree | 1 | 0 | 0 | 0 | 0 |

- queue: `[1]`

Pop `1` from the queue
- pop `1` from the queue

```mermaid
flowchart LR
Expand All @@ -184,8 +194,8 @@ flowchart LR
| in-degree | 0 | 0 | 0 | 0 | 0 |

- queue: `[0]`

Pop `0` from the queue
- pop `0` from the queue
- All courses are taken. Return `True`.

=== "Python"

Expand Down
12 changes: 12 additions & 0 deletions docs/blind75/stack.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ comments: True

## 20. Valid Parentheses

- Determine if the input string is valid.
- Steps for the string `()[]{}`:

| char | action | stack |
| ---- | ------ | ----- |
| `(` | push | "\(" |
| `)` | pop | "" |
| `[` | push | "\[" |
| `]` | pop | "" |
| `{` | push | "\{" |
| `}` | pop | "" |

=== "Python"

```python
Expand Down
19 changes: 19 additions & 0 deletions docs/blind75/tries.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,25 @@ comments: True

## 208. Implement Trie (Prefix Tree)

## Trie

- A trie is a tree-like data structure whose nodes store the letters of an alphabet.

```mermaid
flowchart TD
Root(( ))
Root --- C1(("C"))
Root --- D((D))
C1 --- A1(("A"))
A1 --- T1(("T"))
A1 --- R1(("R"))
A1 --- N((N))
Root --- B1((B))
B1 --- A2((A))
A2 --- T2((T))
A2 --- R2((R))
```

=== "Python"

```python
Expand Down
4 changes: 4 additions & 0 deletions docs/graph_theory/mst.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ MST

## 1168. Optimize Water Distribution in a Village

![1168_0](../assets/1168_0.png)

![1168_1](../assets/1168_1.png)

=== "Python"

```python
Expand Down
13 changes: 13 additions & 0 deletions docs/graph_theory/standard_traversal.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ comments: True

## 547. Number of Provinces

- Return the number of provinces.

### Union Find

- Find by Path Compression
- Union by Rank
- Time Complexity: O(log(n))
- Space Complexity: O(n)

```python title="template/union_find.py"
--8<-- "template/union_find.py"
```

=== "Python"

```python
Expand Down
38 changes: 28 additions & 10 deletions docs/graph_theory/topological_sort.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ comments: True
- Return true if it is possible to finish all courses, otherwise return false.
- Dependency relationships imply the topological sort algorithm.
- Cycle detection
- Topological Sort
- DAG (Directed Acyclic Graph)
- Time complexity: O(V+E)
- Space complexity: O(V+E)
- Prerequisites: Indegree (Look at the problem [1557. Minimum Number of Vertices to Reach All Nodes](#1557-minimum-number-of-vertices-to-reach-all-nodes))
- Indegree: Number of incoming edges to a vertex
- Applications: task scheduling, course scheduling, build systems, dependency resolution, compiler optimization, etc.

![ts1](../assets/graph_ts1.png){width=300px}

![ts2](../assets/graph_ts2.png){width=300px}

Course to prerequisites mapping

```mermaid
flowchart LR
Expand All @@ -19,6 +32,7 @@ flowchart LR
1((1)) --> 4((4))
```

Prerequisites to course mapping

```mermaid
flowchart LR
Expand Down Expand Up @@ -52,8 +66,7 @@ Initialize
| in-degree | 2 | 2 | 0 | 1 | 0 |

- queue: `[2, 4]`

Pop `2` from the queue
- pop `2` from the queue

```mermaid
flowchart LR
Expand All @@ -68,8 +81,7 @@ flowchart LR
| in-degree | 1 | 2 | 0 | 1 | 0 |

- queue: `[4]`

Pop `4` from the queue
- pop `4` from the queue

```mermaid
flowchart LR
Expand All @@ -82,8 +94,7 @@ flowchart LR
| in-degree | 1 | 1 | 0 | 0 | 0 |

- queue: `[3]`

Pop `3` from the queue
- pop `3` from the queue

```mermaid
flowchart LR
Expand All @@ -95,8 +106,7 @@ flowchart LR
| in-degree | 1 | 0 | 0 | 0 | 0 |

- queue: `[1]`

Pop `1` from the queue
- pop `1` from the queue

```mermaid
flowchart LR
Expand All @@ -108,8 +118,8 @@ flowchart LR
| in-degree | 0 | 0 | 0 | 0 | 0 |

- queue: `[0]`

Pop `0` from the queue
- pop `0` from the queue
- All courses are taken. Return `True`.

=== "Python"

Expand All @@ -131,6 +141,10 @@ Pop `0` from the queue

## 210. Course Schedule II

- Return the ordering of courses you should take to finish all courses. If there are multiple valid answers, return any of them.

![0207](../assets/0207.png){width=300px}

=== "Python"

```python
Expand All @@ -151,6 +165,8 @@ Pop `0` from the queue

## 269. Alien Dictionary

- Return the correct order of characters in the alien language.

=== "Python"

```python
Expand All @@ -171,6 +187,8 @@ Pop `0` from the queue

## 1203. Sort Items by Groups Respecting Dependencies

- Return any permutation of the items that satisfies the requirements.

=== "Python"

```python
Expand Down
10 changes: 10 additions & 0 deletions docs/grind75/binary_tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ comments: True

## 199. Binary Tree Right Side View

```plaintext
____1 <---
/ \
2__ 2 <--- Look at the rightmost node at each level
/ \ \
3 4 3 <---
/
5 <---
```

=== "Python"

```python
Expand Down
30 changes: 20 additions & 10 deletions docs/grind75/graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,19 @@ comments: True
- Return true if it is possible to finish all courses, otherwise return false.
- Dependency relationships imply the topological sort algorithm.
- Cycle detection
- Topological Sort
- DAG (Directed Acyclic Graph)
- Time complexity: O(V+E)
- Space complexity: O(V+E)
- Prerequisites: Indegree (Look at the problem [1557. Minimum Number of Vertices to Reach All Nodes](#1557-minimum-number-of-vertices-to-reach-all-nodes))
- Indegree: Number of incoming edges to a vertex
- Applications: task scheduling, course scheduling, build systems, dependency resolution, compiler optimization, etc.

![ts1](../assets/graph_ts1.png){width=300px}

![ts2](../assets/graph_ts2.png){width=300px}

Course to prerequisites mapping

```mermaid
flowchart LR
Expand All @@ -110,6 +123,7 @@ flowchart LR
1((1)) --> 4((4))
```

Prerequisites to course mapping

```mermaid
flowchart LR
Expand Down Expand Up @@ -143,8 +157,7 @@ Initialize
| in-degree | 2 | 2 | 0 | 1 | 0 |

- queue: `[2, 4]`

Pop `2` from the queue
- pop `2` from the queue

```mermaid
flowchart LR
Expand All @@ -159,8 +172,7 @@ flowchart LR
| in-degree | 1 | 2 | 0 | 1 | 0 |

- queue: `[4]`

Pop `4` from the queue
- pop `4` from the queue

```mermaid
flowchart LR
Expand All @@ -173,8 +185,7 @@ flowchart LR
| in-degree | 1 | 1 | 0 | 0 | 0 |

- queue: `[3]`

Pop `3` from the queue
- pop `3` from the queue

```mermaid
flowchart LR
Expand All @@ -186,8 +197,7 @@ flowchart LR
| in-degree | 1 | 0 | 0 | 0 | 0 |

- queue: `[1]`

Pop `1` from the queue
- pop `1` from the queue

```mermaid
flowchart LR
Expand All @@ -199,8 +209,8 @@ flowchart LR
| in-degree | 0 | 0 | 0 | 0 | 0 |

- queue: `[0]`

Pop `0` from the queue
- pop `0` from the queue
- All courses are taken. Return `True`.

=== "Python"

Expand Down
Loading

0 comments on commit 064cc78

Please sign in to comment.