feat: add NeetCode roadmap extractor with dependency graph
- extract.mjs: idempotent script that fetches neetcode.io JS chunks, extracts topic dependency graph (18 topics, 21 edges) and problems (965 total, 199 NeetCode 150) - out/roadmap.json: full data (graph + all problems + courses) - out/roadmap-neetcode150.json: filtered to NeetCode 150 only - out/roadmap.dot: Graphviz visualization - out/roadmap.org: org-mode with TODO checklists, Python/C++ links - neetcode-roadmap-graph.json: standalone edge list - neetcode-roadmap.dot: standalone DOT file Also reformats subarray table in qn_00.org
This commit is contained in:
+21
-21
@@ -695,18 +695,18 @@ Time: O(n * 32), Space: O(32) per step
|
||||
What is the master keyword-to-algorithm mapping for subarray problems?
|
||||
|
||||
** Back
|
||||
| Problem Phrase | Array Property | Algorithm |
|
||||
|---------------|---------------|-----------|
|
||||
| "Continuous subarray + Sum = K" | Only positive numbers | **Sliding Window** (O(1) space) |
|
||||
| "Continuous subarray + Sum = K" | Positive & negative | **Prefix Sum + Hash Map** (O(n) space) |
|
||||
| "Divisible by K" or "Multiple of X" | Any numbers | **Prefix Remainder + Hash Map** (sum % K) |
|
||||
| "Equal number of X and Y" | Any numbers | **Value Mapping** (X→1, Y→-1) + Prefix Sum Map |
|
||||
| "Maximum / Minimum Sum" | Any numbers | **Kadane's Algorithm** (DP) |
|
||||
| "Subarray Sum + Frequent Updates" | Element mutations | **Fenwick Tree / Segment Tree** |
|
||||
| "Subarray product = K" | No zeros | **Prefix Product** (division) |
|
||||
| "Subarray product positive/negative" | Any numbers | **Parity tracking** of negative count |
|
||||
| "Subarray XOR = K" | Any numbers | **Prefix XOR + Hash Map** |
|
||||
| "Subarray OR / AND" | Any numbers | **Set of results** (bounded by 32 changes) |
|
||||
| Problem Phrase | Array Property | Algorithm |
|
||||
|--------------------------------------+-----------------------+----------------------------------------------|
|
||||
| "Continuous subarray + Sum = K" | Only positive numbers | **Sliding Window** (O(1) space) |
|
||||
| "Continuous subarray + Sum = K" | Positive & negative | **Prefix Sum + Hash Map** (O(n) space) |
|
||||
| "Divisible by K" or "Multiple of X" | Any numbers | **Prefix Remainder + Hash Map** (sum % K) |
|
||||
| "Equal number of X and Y" | Any numbers | **Value Mapping** (X→1, Y→-1) + Prefix Sum Map |
|
||||
| "Maximum / Minimum Sum" | Any numbers | **Kadane's Algorithm** (DP) |
|
||||
| "Subarray Sum + Frequent Updates" | Element mutations | **Fenwick Tree / Segment Tree** |
|
||||
| "Subarray product = K" | No zeros | **Prefix Product** (division) |
|
||||
| "Subarray product positive/negative" | Any numbers | **Parity tracking** of negative count |
|
||||
| "Subarray XOR = K" | Any numbers | **Prefix XOR + Hash Map** |
|
||||
| "Subarray OR / AND" | Any numbers | **Set of results** (bounded by 32 changes) |
|
||||
|
||||
* Subarray Sum — Modular Arithmetic Insight [algorithm:interview]
|
||||
:PROPERTIES:
|
||||
@@ -747,15 +747,15 @@ The core philosophy of prefix sums is: **accumulate history as you traverse line
|
||||
|
||||
This generalizes far beyond addition:
|
||||
|
||||
| Problem | Mapping | Reduces To |
|
||||
|---------|---------|-----------|
|
||||
| Equal 0s and 1s | 0→-1, 1→+1 | Subarray sum = 0 |
|
||||
| Equal odd/even | even→+1, odd→-1 | Subarray sum = 0 |
|
||||
| Equal vowels/consonants | vowel→+1, consonant→-1 | Subarray sum = 0 |
|
||||
| Equal A/B/C counts | Track (c_A-c_B, c_B-c_C) | Prefix state tuple repeats |
|
||||
| Subarray product | Prefix product | Division (handle zeros) |
|
||||
| Subarray XOR | Prefix XOR | XOR is invertible |
|
||||
| Subarray sum | Prefix sum | Subtraction |
|
||||
| Problem | Mapping | Reduces To |
|
||||
|-------------------------+--------------------------+----------------------------|
|
||||
| Equal 0s and 1s | 0→-1, 1→+1 | Subarray sum = 0 |
|
||||
| Equal odd/even | even→+1, odd→-1 | Subarray sum = 0 |
|
||||
| Equal vowels/consonants | vowel→+1, consonant→-1 | Subarray sum = 0 |
|
||||
| Equal A/B/C counts | Track (c_A-c_B, c_B-c_C) | Prefix state tuple repeats |
|
||||
| Subarray product | Prefix product | Division (handle zeros) |
|
||||
| Subarray XOR | Prefix XOR | XOR is invertible |
|
||||
| Subarray sum | Prefix sum | Subtraction |
|
||||
|
||||
The pattern:
|
||||
1. Define a state that accumulates as you traverse
|
||||
|
||||
Reference in New Issue
Block a user