> ## Documentation Index
> Fetch the complete documentation index at: https://akshanshgusain.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Speed Drills

## What Are Speed Drills?

Speed drills are short, repetitive, high-intensity DSA implementation exercises designed to:

* Improve code recall speed (from concept to code).
* Build muscle memory for common algorithms and patterns.
* Reduce the cognitive load in real interviews (so you think about approach, not syntax).
* Increase your ability to write bug-free template code under pressure.

<Info>
  Think of them as the LeetCode equivalent of warm-up and sprint intervals in athletic training.
  You’re not solving new problems here — you’re practicing templates and pattern recognition until they become second nature.
</Info>

***

## What Comes Under Speed Drills? (Types of Drills)

Speed drills focus on the core algorithmic building blocks that form 90% of coding interviews.
We’ll divide them by category.

### 1. Core Algorithmic Templates (Implement Blindly)

These are must be able to write in {'<'} 2 mins items:

| Category         | Algorithm                          | Time Target | Notes                               |
| :--------------- | :--------------------------------- | :---------- | :---------------------------------- |
| Graphs           | DFS (recursive + iterative)        | {'<'}2m     | Must handle visited\[] + edge cases |
| Graphs           | BFS (queue-based)                  | {'<'}2m     | Standard template                   |
| Graphs           | Topological Sort (Kahn + DFS)      | {'<'}3m     | Practice both                       |
| Trees            | Pre/In/Post-order traversal        | {'<'}2m     | Write all 3 without thinking        |
| Trees            | Level-order traversal              | {'<'}2m     | BFS variant                         |
| DP               | Memoization + Tabulation templates | {'<'}4m     | E.g., Fibonacci, Knapsack, LIS      |
| Arrays           | Two pointers                       | {'<'}2m     | Move left/right until condition     |
| Arrays           | Sliding window                     | {'<'}2m     | Variable window size                |
| Searching        | Binary Search + variants           | {'<'}2m     | First/last occurrence, boundary     |
| Heaps            | Insert, Pop, Heapify               | {'<'}2m     | Min/max heap operations             |
| Linked Lists     | Reverse, Merge, Find cycle         | {'<'}2m     | Fast/slow pointer mastery           |
| Hashing          | Frequency map pattern              | {'<'}1.5m   | dict counter                        |
| Sorting          | QuickSort, MergeSort skeleton      | {'<'}3m     | iterative + recursive               |
| Recursion        | Backtracking skeleton              | {'<'}3m     | base + loop + undo step             |
| Stack/Queue      | Monotonic Stack + Queue            | {'<'}3m     | “next greater element”              |
| Bit Manipulation | Set/Clear/Toggle/Get               | {'<'}2m     | Fundamental ops                     |
| Math             | GCD/LCM, Sieve of Eratosthenes     | {'<'}3m     | Must recall syntax                  |

### 2. Pattern-Based Recognition Drills

Once you can code the base templates fast, you move to pattern recognition speed drills — identifying the pattern from
problem statements within 1–2 minutes.
Common Drills:

| Pattern Name            | Typical Problems                                       | Key Idea                           |
| :---------------------- | :----------------------------------------------------- | :--------------------------------- |
| Sliding Window          | “Max sum subarray”, “Longest substring without repeat” | Expand & shrink window dynamically |
| Two Pointers            | “Container with most water”, “Three sum”               | Move inward to meet condition      |
| Binary Search on Answer | “Aggressive cows”, “Capacity to ship packages”         | Binary search feasible region      |
| DFS/BFS Graph           | “Number of Islands”, “Rotten Oranges”                  | Traverse connected components      |
| Union-Find              | “Friend circles”, “Accounts merge”                     | Grouping / connectivity            |
| Topological Sort        | “Course Schedule”                                      | Dependency resolution              |
| Backtracking            | “N-Queens”, “Subset sum”                               | Explore + undo                     |
| DP 1D                   | “House Robber”, “Fibonacci”                            | dp\[i] from dp\[i-1], dp\[i-2]     |
| DP 2D                   | “LCS”, “Knapsack”                                      | 2D grid transitions                |
| Prefix Sum              | “Subarray sum K”, “Range query”                        | Precompute cumulative sums         |
| Greedy                  | “Intervals”, “Job sequencing”                          | Sort + choose locally optimal      |
| HashMap/Freq            | “Anagram check”, “Majority element”                    | Counting & lookup                  |
| Heap                    | “Kth largest”, “Merge k lists”                         | Maintain min/max heap              |
| Sorting + Merge         | “Intervals merge”, “Meeting rooms”                     | Sort, then merge                   |

### 3. Structural “Mini Drills”

These are mini 10–15 min sets of 4–6 tiny tasks, done fast and repeatedly.

Example structure for a “Graph drill” session:

```golang theme={null}
Drill 1: Write DFS (recursive) on adjacency list — stop timer.
Drill 2: Write BFS (queue) — stop timer.
Drill 3: Modify DFS to detect a cycle in directed graph.
Drill 4: Write Topo Sort (DFS + Stack).
Drill 5: Write Kahn’s algorithm (queue-based topo).
Drill 6: Add time & space complexity annotation.
```

<Tip>Total time: 10–15 minutes. Repeat daily for different topics.</Tip>

***

## When to practice?

### 1. Daily Micro Speed Drill (5–15 minutes)

* Every weekday, during your DSA session, end with speed drills.
* Pick 1 topic per day (cycling weekly):

| Day | Topic                     |
| :-- | :------------------------ |
| Mon | Graphs (DFS/BFS)          |
| Tue | Trees                     |
| Wed | Arrays / Two pointers     |
| Thu | Binary search / DP        |
| Fri | Misc (heaps, math, stack) |

### 2. Weekly Deep Speed Session (Saturday, 45–60m)

* Every weekend morning (after 1–2h of regular DSA):
  * Pick 2 core patterns (e.g., DP + Sliding Window).
  * Write 5 problems each from memory, timed.
  * Compare to target thresholds (see below).
* Track in your Speed Log Sheet (problem | pattern | time | correctness | notes).

| Problem       | Pattern | Time (m) | Pass | Notes        |
| :------------ | :------ | :------- | :--- | :----------- |
| DFS recursive | Graph   | 2.0      | ✅    | Fine         |
| BFS           | Graph   | 1.8      | ✅    | Good         |
| Detect Cycle  | Graph   | 3.5      | ⚠️   | Review logic |

***

## 4. Speed Targets & Measurement

Every 2 weeks, your median implementation time across 10 speed drills should hit the targets:

| Week       | Target Template Time | Example                     |
| :--------- | :------------------- | :-------------------------- |
| Week 1–2   | 5–6 min              | DFS from scratch            |
| Week 3–4   | 3–4 min              | BFS, Two-pointer            |
| Week 5–6   | 2.5–3 min            | DP skeleton                 |
| Week 7–8   | {'<'}2 min           | Graphs, Arrays, Linked list |
| Week 9–10  | 1.5–2 min            | Sliding window              |
| Week 11–12 | 1–1.5 min            | Final performance           |

***

## 5. How to Perform a Speed Drill (exact steps)

1. Pick a template topic (e.g., BFS).
2. Set timer (e.g., 3 minutes).
3. Start writing from memory — no IDE autocomplete.
4. Code complete function with small test harness (optional).
5. Stop timer.
6. Verify correctness quickly (does it compile/return expected).
7. Record time + error count in log.
8. Repeat 5–6 times with small variations (directed/undirected, recursive/iterative).

| Drill | Topic          | Time (min) | Errors | Notes             |
| :---- | :------------- | :--------- | :----- | :---------------- |
| 1     | DFS recursive  | 2.3        | 0      | OK                |
| 2     | BFS queue      | 2.1        | 0      | OK                |
| 3     | Topo Sort DFS  | 3.4        | 1      | Missed stack push |
| 4     | Topo Sort Kahn | 2.8        | 0      | Perfect           |
| 5     | Detect cycle   | 3.2        | 0      | OK                |

***

## 6. Speed Drill Kit Setup

```golang theme={null}
speed_drills/
├── graph_dfs_bfs.py
├── topo_sort_dfs_kahn.py
├── two_pointer_sliding_window.py
├── binary_search_variants.py
├── dp_memo_tab.py
├── heap_operations.py
├── linked_list_reverse_merge.py
├── stack_queue_monotonic.py
├── recursion_backtracking.py
├── bit_ops.py

```

***

## Program

**Key components:**

* Weekly short speed drills (daily micro-sessions)
* Weekly long speed drills (one session per week)
* Coverage mapping (which topics/pattern groups from the sheet map to which drill weeks)
* Tracking & metrics (time logs, error logs, improvement targets)
* Variation & review (once you’ve coded, revisit the hardest ones, add to SRS)

### Mapping

| Topic Cluster                                  | Key Patterns / Templates to Drill                                                              |
| :--------------------------------------------- | :--------------------------------------------------------------------------------------------- |
| Basic programming/build-up (first \~30)        | Print recursion, basic loops, sum, factorial — drill minimal extra but ensures syntax fluency. |
| Sorting & Searching                            | QuickSort/MergeSort skeleton, binary search variants, 2D array search.                         |
| Arrays & Math                                  | Two pointers, sliding window, prefix sums, fast arithmetic.                                    |
| Strings                                        | KMP/Z-algorithm, substring search, string matching templates.                                  |
| Linked Lists                                   | Reverse, merge, cycle detection, fast/slow pointer.                                            |
| Stacks/Queues                                  | Monotonic stack, implement stack/queue, next greater element.                                  |
| Trees/BST                                      | Traversals, LCA, level-order, reconstruct tree skeletons.                                      |
| Graphs                                         | DFS/BFS iterative & recursive, cycle detect, topological sort, shortest path skeletons.        |
| Dynamic Programming                            | 1D/2D dp, memo→tabulation conversions, knapsack, LIS.                                          |
| Bit Manipulation                               | Basic bit ops, masks, toggle, count bits.                                                      |
| Advanced DS (Tries, Segment Trees, Union-Find) | Tries insert/search, union-find union/find template, segment tree build/query.                 |
| Mixed/Hybrid problems                          | Combine patterns: sliding window + bitmask, graph + dp, etc.                                   |

### Weekly Short & Long Sessions (12-Week Drill Schedule)

| Week | Topic Focus                            | Daily micro-drill pattern                                           | Saturday long drill (45-60min)                                                   |
| :--- | :------------------------------------- | :------------------------------------------------------------------ | :------------------------------------------------------------------------------- |
| W1   | Arrays & Math basics                   | 1 array template per day (two-pointer / prefix)                     | Pick 4 array problems from sheet, time each, target {'<'}4min each               |
| W2   | Strings + Sorting                      | Each day: string template or sorting template (quick sort skeleton) | Drill: 3 string problems + 2 sorting problems                                    |
| W3   | Linked Lists + Stacks/Queues           | Day: reverse list, merge list, monotonic stack                      | Drill: 2 linked-list problems + 2 stack/queue problems                           |
| W4   | Trees/BST basics                       | Day: traversal skeletons, LCA skeleton                              | Drill: 3 tree problems (easy→medium)                                             |
| W5   | Graph fundamentals                     | Day: DFS, BFS templates                                             | Drill: 4 graph problems (component, cycle detect)                                |
| W6   | Binary Search & Math/Bit               | Day: binary search variants, bit ops                                | Drill: 3 binary search + 2 bit-manip problems                                    |
| W7   | Dynamic Programming (basic)            | Day: 1D dp, memo → tabulation                                       | Drill: 4 dp problems (easy/medium)                                               |
| W8   | Backtracking & Hybrid                  | Day: recursion/backtracking skeletons                               | Drill: 3 backtracking + 2 hybrid (dp+graph)                                      |
| W9   | Advanced DS (Tries/Union-Find/Segment) | Day: trie insert/search, union-find union/find                      | Drill: 3 advanced DS problems                                                    |
| W10  | Greedy + Mixed Patterns                | Day: greedy skeleton (intervals) + mixed                            | Drill: 2 greedy + 2 mixed pattern problems                                       |
| W11  | Speed consolidation                    | Day: pick weakest templates & redo                                  | Drill: 5 problems drawn from your error log, target {'<'}3min each               |
| W12  | Final sweep & weak-points              | Day: alternate templates every day                                  | Drill: 5 problems (mixed topics) with full speed target {'<'}2min where possible |

### Coverage Strategy over 450 Problems

* Map the 450 problems into the topic clusters (as above). Each week you handle new problems + revisit older ones via speed drills.
* Use a problem queue: Each week, assign “new problems” from the sheet (target: \~38 problems/week). Among them, select 5–10 as speed-drill candidates (i.e., templates you’ll learn to write fast).
* Mark them in your spreadsheet with categories:
  * T = Template (for speed drills)
  * R = Re-solve (timed)
  * D = Deep-fix (hard / failed)
    Make sure every template problem appears in a daily micro-drill within that week/one after.

#### Example Week 1 Speed Drill Plan (detailed)

**Week 1 (Arrays & Math Basics)**

Daily micro-drill topics:

* **Mon**: Two-pointer skeleton (e.g., “3Sum”)
* **Tue**: Prefix-sum skeleton (e.g., “Subarray Sum K”)
* **Wed**: Sliding window skeleton (e.g., “Longest Substring Without Repeating”)
* **Thu**: Basic sorting skeleton (e.g., “Merge two sorted arrays without extra space”)
* **Fri**: Math/array variant (e.g., “Kadane’s algorithm for max subarray sum”)
* **Saturday long drill**: pick 5 problems from sheet (Arrays medium/hard) → time each, review.
* **Sunday**: Weekly topic test on Arrays (timed) + speed drill review (convert templates you failed into SRS cards).
