migrate 392 questions to pattern format
This commit is contained in:
@@ -177,3 +177,83 @@ patterns:
|
||||
- Flood fill
|
||||
- Rotting oranges
|
||||
- Word search in grid
|
||||
|
||||
- name: Topological Sort
|
||||
slug: topological-sort
|
||||
description: Order vertices in a directed acyclic graph (DAG) such that for every edge u→v, u comes before v.
|
||||
when_to_use: |
|
||||
- Course scheduling with prerequisites
|
||||
- Build order / dependency resolution
|
||||
- Task scheduling with dependencies
|
||||
- Alien dictionary problems
|
||||
- Detecting cycles in directed graphs
|
||||
|
||||
- name: Bit Manipulation
|
||||
slug: bit-manipulation
|
||||
description: Use bitwise operations (AND, OR, XOR, shifts) to solve problems efficiently.
|
||||
when_to_use: |
|
||||
- Finding single/missing numbers (XOR tricks)
|
||||
- Counting set bits
|
||||
- Power of two checks
|
||||
- Subset generation with bitmasks
|
||||
- Swapping without temp variable
|
||||
|
||||
- name: Counting / Bucket Sort
|
||||
slug: counting-sort
|
||||
description: Sort or process elements by using their values as indices when the range is bounded.
|
||||
when_to_use: |
|
||||
- Top K frequent elements (bounded frequency range)
|
||||
- Sort Colors (Dutch National Flag)
|
||||
- H-Index calculation
|
||||
- Problems where values are in known small range
|
||||
- Frequency-based grouping
|
||||
|
||||
- name: Cyclic Sort
|
||||
slug: cyclic-sort
|
||||
description: Place each element at its correct index when values are in range [1, n] or [0, n-1].
|
||||
when_to_use: |
|
||||
- Find missing number in [1, n]
|
||||
- Find duplicate in [1, n]
|
||||
- Find all missing/duplicate numbers
|
||||
- First missing positive
|
||||
- Set mismatch problems
|
||||
|
||||
- name: Divide and Conquer
|
||||
slug: divide-and-conquer
|
||||
description: Split problem into smaller subproblems, solve recursively, and combine results.
|
||||
when_to_use: |
|
||||
- Merge sort and related problems
|
||||
- Quick select for kth element
|
||||
- Binary search variants
|
||||
- Matrix multiplication
|
||||
- Closest pair of points
|
||||
|
||||
- name: Hashing
|
||||
slug: hashing
|
||||
description: Use hash tables for O(1) average lookup, insertion, and deletion.
|
||||
when_to_use: |
|
||||
- Two Sum and variants
|
||||
- Detecting duplicates
|
||||
- Frequency counting
|
||||
- Anagram grouping
|
||||
- LRU/LFU cache implementation
|
||||
|
||||
- name: Matrix Manipulation
|
||||
slug: matrix-manipulation
|
||||
description: Transform or process 2D matrices using rotation, transposition, or in-place modifications.
|
||||
when_to_use: |
|
||||
- Rotate image 90 degrees
|
||||
- Spiral matrix traversal
|
||||
- Set matrix zeroes
|
||||
- Transpose matrix
|
||||
- Game of Life state updates
|
||||
|
||||
- name: Synchronization
|
||||
slug: synchronization
|
||||
description: Coordinate multiple threads or processes using locks, semaphores, or barriers.
|
||||
when_to_use: |
|
||||
- Print in order problems
|
||||
- Producer-consumer patterns
|
||||
- Dining philosophers
|
||||
- Building H2O molecules
|
||||
- Concurrent data structure design
|
||||
|
||||
Reference in New Issue
Block a user