mirror of
https://github.com/prdlk/leetcode.git
synced 2026-11-02 21:22:43 +00:00
233 lines
9.0 KiB
TypeScript
233 lines
9.0 KiB
TypeScript
/**
|
|
* The Appendix glossary: one term per LeetCode topic tag that problem pages
|
|
* carry but no campaign topic teaches (not a key of `topic-landings.ts`).
|
|
* `pages/appendix.astro` renders each as a card — icon, category, definition,
|
|
* and the solved problems carrying the tag — anchored at `/appendix#<slug>`,
|
|
* which is where `tagTarget()` sends that tag's badge on a problem page.
|
|
*
|
|
* Hand-written: `apps/cli/sync.ts` only checks it, warning about a carried
|
|
* tag with no entry (its card renders bare), an entry whose tag a campaign
|
|
* topic now teaches (dead weight, delete it), and an icon that is a topic's
|
|
* (`TOPIC_ICONS`) or another term's — the icon is also the one on every
|
|
* badge linking here, so it must not read as anything else. Plain data, no
|
|
* Astro imports: sync imports this file under Bun.
|
|
*/
|
|
|
|
export type AppendixCategory = "Data Structures" | "Algorithms" | "Techniques";
|
|
|
|
export interface AppendixTerm {
|
|
/** LeetCode's tag name. */
|
|
name: string;
|
|
/** Lucide icon, unique across terms and topics. */
|
|
icon: string;
|
|
category: AppendixCategory;
|
|
/** One sentence: what the term means, the way a solution uses it. */
|
|
definition: string;
|
|
}
|
|
|
|
export const APPENDIX: Record<string, AppendixTerm> = {
|
|
// ── data structures ──────────────────────────────────────────────
|
|
array: {
|
|
name: "Array",
|
|
icon: "list-ordered",
|
|
category: "Data Structures",
|
|
definition: "A contiguous, index-addressed sequence: O(1) access by position, O(n) to insert or delete in the middle.",
|
|
},
|
|
"binary-tree": {
|
|
name: "Binary Tree",
|
|
icon: "git-branch",
|
|
category: "Data Structures",
|
|
definition: "A rooted tree in which every node has at most two children, left and right.",
|
|
},
|
|
"directed-acyclic-graph": {
|
|
name: "Directed Acyclic Graph",
|
|
icon: "route",
|
|
category: "Data Structures",
|
|
definition: "A directed graph with no cycles, which is exactly what lets its nodes be put in a topological order.",
|
|
},
|
|
"doubly-linked-list": {
|
|
name: "Doubly-Linked List",
|
|
icon: "link-2",
|
|
category: "Data Structures",
|
|
definition: "A linked list whose nodes point to both neighbours, so a node you already hold is unlinked in O(1).",
|
|
},
|
|
graph: {
|
|
name: "Graph Theory",
|
|
icon: "share-2",
|
|
category: "Data Structures",
|
|
definition: "Nodes joined by edges, directed or not, weighted or not, stored as an adjacency list or matrix.",
|
|
},
|
|
"k-d-tree": {
|
|
name: "K-D Tree",
|
|
icon: "axis-3d",
|
|
category: "Data Structures",
|
|
definition: "A binary tree that splits k-dimensional points on alternating axes, for nearest-neighbour and range queries.",
|
|
},
|
|
queue: {
|
|
name: "Queue",
|
|
icon: "list-end",
|
|
category: "Data Structures",
|
|
definition: "First in, first out: push at the back, pop from the front, both O(1).",
|
|
},
|
|
string: {
|
|
name: "String",
|
|
icon: "quote",
|
|
category: "Data Structures",
|
|
definition: "A sequence of characters; solutions lean on its small alphabet, its substrings, and its immutability.",
|
|
},
|
|
tree: {
|
|
name: "Tree",
|
|
icon: "tree-deciduous",
|
|
category: "Data Structures",
|
|
definition: "A connected acyclic graph, usually rooted, in which every node but the root has exactly one parent.",
|
|
},
|
|
|
|
// ── algorithms ───────────────────────────────────────────────────
|
|
"bidirectional-search": {
|
|
name: "Bidirectional Search",
|
|
icon: "move-horizontal",
|
|
category: "Algorithms",
|
|
definition: "Search from the start and the goal at once and stop where the frontiers meet, about 2·b^(d/2) states instead of b^d.",
|
|
},
|
|
"binary-lifting": {
|
|
name: "Binary Lifting",
|
|
icon: "chevrons-up",
|
|
category: "Algorithms",
|
|
definition: "Precompute every node's 2^k-th ancestor so any k-th ancestor, and so the LCA, takes O(log n) jumps.",
|
|
},
|
|
"bit-manipulation": {
|
|
name: "Bit Manipulation",
|
|
icon: "binary",
|
|
category: "Algorithms",
|
|
definition: "Treat integers as bit vectors: masks, shifts, and XOR in place of arithmetic or extra memory.",
|
|
},
|
|
"bracket-sequences": {
|
|
name: "Bracket Sequences",
|
|
icon: "parentheses",
|
|
category: "Algorithms",
|
|
definition: "Strings of opening and closing brackets; balanced means the running depth never dips below zero and ends at zero.",
|
|
},
|
|
"bucket-sort": {
|
|
name: "Bucket Sort",
|
|
icon: "container",
|
|
category: "Algorithms",
|
|
definition: "Scatter values into buckets by range or frequency, then read the buckets in order: linear when the key range is bounded.",
|
|
},
|
|
"complete-knapsack": {
|
|
name: "Complete Knapsack",
|
|
icon: "package-plus",
|
|
category: "Algorithms",
|
|
definition: "Knapsack in which every item may be taken any number of times, so the DP walks capacity upward and reuses the row.",
|
|
},
|
|
"divide-and-conquer": {
|
|
name: "Divide and Conquer",
|
|
icon: "split",
|
|
category: "Algorithms",
|
|
definition: "Split the input into independent parts, solve each recursively, and combine their answers.",
|
|
},
|
|
"floyds-cycle-finding-algorithm": {
|
|
name: "Floyd's Cycle Finding Algorithm",
|
|
icon: "repeat",
|
|
category: "Algorithms",
|
|
definition: "A slow and a fast pointer meet inside any cycle; restarting one from the head finds the cycle's entry, in O(1) space.",
|
|
},
|
|
"knapsack-problem": {
|
|
name: "Knapsack Problem",
|
|
icon: "backpack",
|
|
category: "Algorithms",
|
|
definition: "Pick items with weights and values to maximise value under a capacity; the 0/1 version is an O(n·W) DP.",
|
|
},
|
|
"longest-common-subsequence": {
|
|
name: "Longest Common Subsequence",
|
|
icon: "diff",
|
|
category: "Algorithms",
|
|
definition: "The longest sequence that appears in order, not necessarily contiguously, in two strings: the classic O(n·m) 2-D DP.",
|
|
},
|
|
"lowest-common-ancestor": {
|
|
name: "Lowest Common Ancestor",
|
|
icon: "git-merge",
|
|
category: "Algorithms",
|
|
definition: "The deepest node of a rooted tree that is an ancestor of both given nodes.",
|
|
},
|
|
memoization: {
|
|
name: "Memoization",
|
|
icon: "database",
|
|
category: "Algorithms",
|
|
definition: "Cache a pure function's result per argument so every subproblem is solved once: top-down dynamic programming.",
|
|
},
|
|
"merge-sort": {
|
|
name: "Merge Sort",
|
|
icon: "blend",
|
|
category: "Algorithms",
|
|
definition: "Sort each half recursively, then merge the two sorted halves: O(n log n), stable, O(n) extra space.",
|
|
},
|
|
quickselect: {
|
|
name: "Quickselect",
|
|
icon: "crosshair",
|
|
category: "Algorithms",
|
|
definition: "Partition around a pivot and recurse into one side only, finding the k-th smallest element in O(n) on average.",
|
|
},
|
|
quicksort: {
|
|
name: "Quicksort",
|
|
icon: "shuffle",
|
|
category: "Algorithms",
|
|
definition: "Partition around a pivot, then sort each side in place: O(n log n) on average, O(n²) at worst.",
|
|
},
|
|
recursion: {
|
|
name: "Recursion",
|
|
icon: "iteration-ccw",
|
|
category: "Algorithms",
|
|
definition: "Solve a problem by calling the same function on smaller inputs until a base case answers directly.",
|
|
},
|
|
simulation: {
|
|
name: "Simulation",
|
|
icon: "monitor-play",
|
|
category: "Algorithms",
|
|
definition: "Carry out the process the statement describes, step by step; the work is modelling the state faithfully.",
|
|
},
|
|
sorting: {
|
|
name: "Sorting",
|
|
icon: "arrow-down-wide-narrow",
|
|
category: "Algorithms",
|
|
definition: "Order the input first so a later step, such as two pointers, a greedy choice, or binary search, becomes possible.",
|
|
},
|
|
"tournament-sort": {
|
|
name: "Tournament Sort",
|
|
icon: "trophy",
|
|
category: "Algorithms",
|
|
definition: "A winner tree of pairwise comparisons: the root is the extreme element, and replaying one path yields the next in O(log n).",
|
|
},
|
|
|
|
// ── techniques ───────────────────────────────────────────────────
|
|
combinatorics: {
|
|
name: "Combinatorics",
|
|
icon: "dices",
|
|
category: "Techniques",
|
|
definition: "Count arrangements and selections (permutations, combinations, Catalan numbers), usually modulo a prime.",
|
|
},
|
|
counting: {
|
|
name: "Counting",
|
|
icon: "tally-5",
|
|
category: "Techniques",
|
|
definition: "Tally occurrences in a hash map or fixed array, then answer from the counts instead of the raw input.",
|
|
},
|
|
design: {
|
|
name: "Design",
|
|
icon: "pencil-ruler",
|
|
category: "Techniques",
|
|
definition: "Implement a class to an API spec, choosing the internals so every operation meets its time bound.",
|
|
},
|
|
geometry: {
|
|
name: "Geometry",
|
|
icon: "shapes",
|
|
category: "Techniques",
|
|
definition: "Points, lines, and areas on a plane or grid: distances, slopes, overlaps, and orientation by cross product.",
|
|
},
|
|
math: {
|
|
name: "Math",
|
|
icon: "calculator",
|
|
category: "Techniques",
|
|
definition: "An arithmetic or number-theory insight (modular arithmetic, GCD, digit manipulation, a closed form) in place of brute force.",
|
|
},
|
|
};
|