From 72bea62663613b8f23e6694e3773a36fe3fbacde Mon Sep 17 00:00:00 2001 From: Kai Chappell Date: Mon, 21 Apr 2025 20:44:21 +0100 Subject: [PATCH] feat(content): add categories and patterns --- backend/data/categories/categories.yaml | 60 +++++++++++ backend/data/patterns/patterns.yaml | 129 ++++++++++++++++++++++++ 2 files changed, 189 insertions(+) create mode 100644 backend/data/categories/categories.yaml create mode 100644 backend/data/patterns/patterns.yaml diff --git a/backend/data/categories/categories.yaml b/backend/data/categories/categories.yaml new file mode 100644 index 0000000..876f6a3 --- /dev/null +++ b/backend/data/categories/categories.yaml @@ -0,0 +1,60 @@ +categories: + - name: Arrays + slug: arrays + description: Problems involving array manipulation, traversal, and transformations. + + - name: Strings + slug: strings + description: Problems focused on string manipulation, pattern matching, and text processing. + + - name: Hash Tables + slug: hash-tables + description: Problems utilizing hash maps for efficient lookups and counting. + + - name: Linked Lists + slug: linked-lists + description: Problems involving singly or doubly linked list operations. + + - name: Trees + slug: trees + description: Problems involving binary trees, BSTs, and tree traversals. + + - name: Graphs + slug: graphs + description: Problems involving graph traversal, shortest paths, and connectivity. + + - name: Dynamic Programming + slug: dynamic-programming + description: Problems requiring optimal substructure and overlapping subproblems. + + - name: Binary Search + slug: binary-search + description: Problems utilizing binary search for efficient searching. + + - name: Sorting + slug: sorting + description: Problems involving sorting algorithms and techniques. + + - name: Stack + slug: stack + description: Problems using LIFO data structure for parsing and tracking. + + - name: Queue + slug: queue + description: Problems using FIFO data structure and BFS traversals. + + - name: Heap + slug: heap + description: Problems using priority queues for top-k and streaming data. + + - name: Two Pointers + slug: two-pointers + description: Problems solved using two pointer technique. + + - name: Recursion + slug: recursion + description: Problems requiring recursive problem decomposition. + + - name: Math + slug: math + description: Problems involving mathematical concepts and number theory. diff --git a/backend/data/patterns/patterns.yaml b/backend/data/patterns/patterns.yaml new file mode 100644 index 0000000..79cc266 --- /dev/null +++ b/backend/data/patterns/patterns.yaml @@ -0,0 +1,129 @@ +patterns: + - name: Two Pointers + slug: two-pointers + description: Use two pointers to traverse data from different positions, often moving toward or away from each other. + when_to_use: | + - Sorted arrays where you need to find pairs + - Linked list cycle detection + - Removing duplicates in-place + - Partitioning arrays + - Palindrome checking + + - name: Sliding Window + slug: sliding-window + description: Maintain a window of elements that slides through the data, tracking a constraint or computing aggregates. + when_to_use: | + - Finding subarrays/substrings with specific properties + - Maximum/minimum sum of fixed-size windows + - Longest substring with at most K distinct characters + - Problems mentioning "contiguous" elements + + - name: Fast & Slow Pointers + slug: fast-slow-pointers + description: Two pointers moving at different speeds, commonly used for cycle detection. + when_to_use: | + - Detecting cycles in linked lists or arrays + - Finding the middle of a linked list + - Finding the start of a cycle + - Happy number problem + + - name: Binary Search + slug: binary-search + description: Efficiently search sorted data by repeatedly dividing the search space in half. + when_to_use: | + - Sorted arrays or search spaces + - Finding boundaries (first/last occurrence) + - Searching in rotated sorted arrays + - Finding peak elements + - Minimizing/maximizing with monotonic constraints + + - name: BFS (Breadth-First Search) + slug: bfs + description: Level-by-level traversal using a queue, optimal for shortest paths in unweighted graphs. + when_to_use: | + - Shortest path in unweighted graphs + - Level-order tree traversal + - Finding all nodes at distance K + - Word ladder problems + - Matrix traversal + + - name: DFS (Depth-First Search) + slug: dfs + description: Explore as deep as possible before backtracking, using recursion or a stack. + when_to_use: | + - Tree/graph traversal + - Path finding + - Detecting cycles + - Topological sorting + - Connected components + - Backtracking problems + + - name: Backtracking + slug: backtracking + description: Build solutions incrementally, abandoning paths that fail to satisfy constraints. + when_to_use: | + - Generating all permutations/combinations + - Sudoku solver + - N-Queens problem + - Subset/partition problems + - Word search in grid + + - name: Dynamic Programming + slug: dynamic-programming + description: Break problems into overlapping subproblems, storing results to avoid recomputation. + when_to_use: | + - Optimization problems (min/max) + - Counting problems + - Problems with optimal substructure + - Sequence alignment + - Knapsack-type problems + + - name: Greedy + slug: greedy + description: Make locally optimal choices at each step, hoping for a global optimum. + when_to_use: | + - Interval scheduling + - Huffman coding + - Minimum spanning tree + - Activity selection + - When local optimum leads to global optimum + + - name: Monotonic Stack + slug: monotonic-stack + description: Stack maintaining elements in sorted order, used for next greater/smaller element problems. + when_to_use: | + - Next greater/smaller element + - Largest rectangle in histogram + - Daily temperatures + - Stock span problem + - Trapping rain water + + - name: Heap / Priority Queue + slug: heap + description: Data structure for efficiently finding min/max elements. + when_to_use: | + - Top K elements + - K-way merge + - Median from data stream + - Task scheduling + - Dijkstra's algorithm + + - name: Union Find + slug: union-find + description: Track disjoint sets with efficient union and find operations. + when_to_use: | + - Connected components in graphs + - Cycle detection in undirected graphs + - Kruskal's minimum spanning tree + - Social network connections + - Accounts merge + + - name: Trie + slug: trie + description: Tree-like data structure for efficient string prefix operations. + when_to_use: | + - Autocomplete systems + - Word dictionary with wildcard search + - Longest common prefix + - Word break problems + - Spell checker