Files
leetcode/apps/docs/content/index.mdx
T

267 lines
7.5 KiB
Plaintext

---
title: Introduction
description: Structured dependency spine based roadmap for solving DSA Problems on leetcode.
icon: play
---
## 1. Linear Structures
:::tip
Data is read in one direction, from the first item to the last. The current position is recorded at each step. All later phases use this skill.
:::
<Columns cols={2}>
<Column>
<Tile
title="Hash Table"
description="A key maps to a value in constant time, which removes the need for a full scan."
href="/leetcode/hash-table"
>
<Icon icon="hash" size={28} />
</Tile>
</Column>
<Column>
<Tile
title="Prefix Sum"
description="A running total is stored at each index, so the sum of any range is one subtraction."
href="/leetcode/prefix-sum"
>
<Icon icon="sigma" size={28} />
</Tile>
</Column>
<Column>
<Tile
title="Two Pointers"
description="Two indices move through the data from different positions and meet at the answer."
href="/leetcode/two-pointers"
>
<Icon icon="arrow-left-right" size={28} />
</Tile>
</Column>
<Column>
<Tile
title="Sliding Window"
description="A range with a start and an end moves across the data, and the contents are updated at each step."
href="/leetcode/sliding-window"
>
<Icon icon="app-window" size={28} />
</Tile>
</Column>
<Column>
<Tile
title="Binary Search"
description="Half of a sorted range is removed at each step until the target is found."
href="/leetcode/binary-search"
>
<Icon icon="search" size={28} />
</Tile>
</Column>
<Column>
<Tile
title="Stack"
description="Items are added and removed from one end, so the last item added is the first item removed."
href="/leetcode/stack"
>
<Icon icon="layers" size={28} />
</Tile>
</Column>
<Column>
<Tile
title="Monotonic Stack"
description="A stack keeps its items in sorted order, which finds the next larger or smaller item in one pass."
href="/leetcode/monotonic-stack"
>
<Icon icon="trending-up" size={28} />
</Tile>
</Column>
</Columns>
## 2. Nodal & Grid
:::tip
The data is in separate parts. Each part points to the next part, or sits next to other parts on a flat surface. An index does not find the next item. The pointers or the neighbors give the path instead.
:::
<Columns cols={2}>
<Column>
<Tile
title="Linked List"
description="Each node points to the next node, and the pointers give the path through the data."
href="/leetcode/linked-list"
>
<Icon icon="link" size={28} />
</Tile>
</Column>
<Column>
<Tile
title="Hybrid Structures"
description="Two structures are combined, such as a hash map and a linked list, to get the best properties of each."
href="/leetcode/hybrid-structures"
>
<Icon icon="combine" size={28} />
</Tile>
</Column>
<Column>
<Tile
title="Matrix Index Math"
description="A two-dimensional grid is read as a flat array through a formula, and the neighbors are found by arithmetic."
href="/leetcode/matrix-index-math"
>
<Icon icon="grid-3x3" size={28} />
</Tile>
</Column>
</Columns>
## 3. Hierarchical
:::tip
Each part points to one or more parts below it. Those parts do the same. The method that solves a small part also solves the large part. This is recursion.
:::
<Columns cols={2}>
<Column>
<Tile
title="Tree DFS"
description="Each branch is followed to its end before the next branch is examined."
href="/leetcode/tree-dfs"
>
<Icon icon="folder-tree" size={28} />
</Tile>
</Column>
<Column>
<Tile
title="Tree BFS"
description="All nodes at one level are visited before the nodes at the next level."
href="/leetcode/tree-bfs"
>
<Icon icon="network" size={28} />
</Tile>
</Column>
<Column>
<Tile
title="Binary Search Tree"
description="Each node holds a value that is larger than its left subtree and smaller than its right subtree."
href="/leetcode/binary-search-tree"
>
<Icon icon="git-fork" size={28} />
</Tile>
</Column>
<Column>
<Tile
title="Heap"
description="The largest or smallest item is always at the top, and it is removed in logarithmic time."
href="/leetcode/heap-priority-queue"
>
<Icon icon="triangle" size={28} />
</Tile>
</Column>
<Column>
<Tile
title="Trie"
description="Each node holds one character, and a path from the root spells a word."
href="/leetcode/trie"
>
<Icon icon="spell-check" size={28} />
</Tile>
</Column>
</Columns>
## 4. Relational
:::tip
Each part can point to any other part. Loops can occur. The method must visit each part one time only. The order of the parts, or the distance between them, is not given in the data. The method finds it.
:::
<Columns cols={2}>
<Column>
<Tile
title="Graph DFS"
description="Each edge is followed to its end, and a visited set prevents a repeat visit."
href="/leetcode/graph-dfs"
>
<Icon icon="waypoints" size={28} />
</Tile>
</Column>
<Column>
<Tile
title="Graph BFS"
description="Nodes are visited in order of distance from the start, which gives the shortest path in an unweighted graph."
href="/leetcode/graph-bfs"
>
<Icon icon="radar" size={28} />
</Tile>
</Column>
<Column>
<Tile
title="Topological Sort"
description="Nodes are put in an order where each node comes after all nodes that point to it."
href="/leetcode/topological-sort"
>
<Icon icon="workflow" size={28} />
</Tile>
</Column>
<Column>
<Tile
title="Union-Find"
description="Two sets are merged and the set of any item is found in near-constant time."
href="/leetcode/union-find"
>
<Icon icon="merge" size={28} />
</Tile>
</Column>
</Columns>
## 5. Decision Space
:::tip
The data has no structure. The method makes one. Each choice makes a new branch. The problem sets the correct method: examine all branches, keep a record of the results already found, or make one choice and do not go back.
:::
<Columns cols={2}>
<Column>
<Tile
title="Backtracking"
description="Each choice makes a branch, and a branch is undone when it does not give a valid result."
href="/leetcode/backtracking"
>
<Icon icon="undo-2" size={28} />
</Tile>
</Column>
<Column>
<Tile
title="1-D DP"
description="The result for each state is stored in a list, and each new result is computed from the results before it."
href="/leetcode/1d-dynamic-programming"
>
<Icon icon="columns-3" size={28} />
</Tile>
</Column>
<Column>
<Tile
title="Multi-D / Grid DP"
description="The result for each state is stored in a table with two or more dimensions, and each cell is computed from its neighbors."
href="/leetcode/multi-d-grid-dp"
>
<Icon icon="table" size={28} />
</Tile>
</Column>
<Column>
<Tile
title="Greedy"
description="The best local choice is made at each step and is not changed later."
href="/leetcode/greedy"
>
<Icon icon="coins" size={28} />
</Tile>
</Column>
<Column>
<Tile
title="Intervals"
description="Ranges with a start and an end are sorted, and then merged, counted, or scheduled."
href="/leetcode/intervals"
>
<Icon icon="calendar-range" size={28} />
</Tile>
</Column>
</Columns>