Documentation Index
Fetch the complete documentation index at: https://resources.devweekends.com/llms.txt
Use this file to discover all available pages before exploring further.
The Mistake Journal System
Every wrong answer contains a lesson. Most competitive programmers make the same mistakes repeatedly because they don’t track them. This chapter gives you a systematic approach to eliminate recurring errors and accelerate your improvement.Why Mistakes Repeat
The Memory Problem
The 5 Categories of CP Mistakes
| Category | Description | Example |
|---|---|---|
| Syntax | Language/compiler errors | Forgetting semicolon, wrong brackets |
| Logic | Algorithm is fundamentally wrong | Wrong recurrence relation |
| Implementation | Right idea, wrong code | Off-by-one, wrong index |
| Edge Cases | Works for most, fails for extremes | n=0, n=1, empty string |
| Careless | Silly mistakes under pressure | Wrong variable name, copy-paste error |
Setting Up Your Mistake Journal
Option 1: Notion Template
The Correct Code
Root Cause Analysis
- Why did I make this mistake?
- What was I thinking when I wrote it?
- What should I have done differently?
Prevention Strategy
- How will I catch this next time?
- What mental check should I add?
- Any template/snippet to prevent this?
Tags
#overflow #off-by-one #edge-case #modulo #binary-searchThe Master Mistake Database
Top 50 Common CP Mistakes
Build your own database. Here’s a starter:Integer Overflow (THE #1 KILLER)
Off-By-One Errors
Modular Arithmetic Pitfalls
Binary Search Edge Cases
Graph Algorithm Mistakes
String Processing Errors
Array Initialization
Analyzing Your Mistakes
Weekly Mistake Review
Every Sunday, review your mistake journal:Count by Category
- Overflow: 3
- Edge cases: 5
- Logic: 2
Identify Patterns
- Binary search: 4 mistakes
- DP: 1 mistake
Check for Repeats
- Integer overflow: Made it twice this week!
Monthly Mistake Trends
- Total mistakes per week (should decrease)
- Repeat mistakes (should decrease faster)
- Time to debug (should decrease)
- New mistake types (sign of tackling harder problems)
The Prevention System
Pre-Coding Checklist
Before you start coding ANY problem, ask:Pre-Submit Checklist
Before hitting submit, verify:The “5 Second Rule”
Mistake Templates by Topic
Binary Search Mistakes
DP Mistakes
Graph Mistakes
Quick Reference: The Mistake Lookup Table
When you get WA or TLE, check this table:| Symptom | Likely Cause | Quick Fix |
|---|---|---|
| Wrong Answer on large input | Integer overflow | Cast to long long |
| Wrong Answer on sample | Logic error | Re-read problem, trace by hand |
| Wrong Answer test 2 | Edge case (n=1) | Add special case handling |
| Time Limit Exceeded | Algorithm too slow | Optimize or change approach |
| TLE with O(n²) | Need O(n log n) | Use sorting/binary search/map |
| Runtime Error | Array out of bounds | Check all array accesses |
| Runtime Error | Stack overflow | Convert recursion to iteration |
| Wrong Answer random tests | Off-by-one error | Check loop bounds carefully |
| Works locally, fails online | Uninitialized variables | Initialize everything |
Building Mistake Immunity
The 3-Strike Rule
If you make the same mistake 3 times:- Create a snippet to prevent it
- Add it to pre-submit checklist
- Teach it to someone else (explaining cements memory)
The Mistake Flashcard System
Create flashcards for your top mistakes:The “Never Again” List
Keep a pinned list of your top 5 most frustrating mistakes:Interview Deep-Dive
You have been keeping a mistake journal for a month and notice that 40% of your WAs are integer overflow. What systemic fix would you implement, and how would you measure its effectiveness?
You have been keeping a mistake journal for a month and notice that 40% of your WAs are integer overflow. What systemic fix would you implement, and how would you measure its effectiveness?
- The systemic fix has three layers: prevention, detection, and verification. Prevention: add
#define int long longto my contest template, or at minimum uselong longfor any variable that participates in multiplication or accumulation. Detection: compile with-fsanitize=undefinedduring local testing, which flags signed overflow at runtime. Verification: add an explicit item to my pre-submit checklist — “scan every multiplication and sum for overflow potential.” - To measure effectiveness, I continue logging mistakes for the next month and compare the overflow WA rate. If it drops from 40% to under 10%, the fix is working. If it persists, the fix is not addressing the root cause — perhaps the overflows are happening in less obvious places like implicit int-to-int multiplication inside STL operations.
- Beyond the immediate fix, I would audit my past overflow bugs and categorize them: (1) product of two ints, (2) running sum exceeding 2 times 10^9, (3) modular arithmetic intermediate values, (4) array size calculations. Each subcategory might need a different prevention strategy.
Describe the '3-strike rule' for recurring bugs. How does converting a recurring mistake into a code snippet prevent it permanently?
Describe the '3-strike rule' for recurring bugs. How does converting a recurring mistake into a code snippet prevent it permanently?
- The 3-strike rule: if I make the same mistake three times (identified via my mistake journal tags), I escalate to a permanent fix. The first occurrence is a learning moment. The second is a warning. The third means my normal coding habits will not prevent this — I need a structural intervention.
- Structural interventions, ranked by effectiveness: (1) A code snippet in my IDE that auto-generates the correct pattern. For example, after my third binary search infinite loop, I created a VS Code snippet
binsearchthat expands to a tested template withlo + (hi - lo) / 2andlo < hi. Now I never hand-write binary search bounds. (2) A checklist item I review before every submission. (3) A macro in my template that handles the case automatically (like safe modular arithmetic). - The snippet approach works because it removes the human from the error-prone step. I do not trust myself to remember
lo + (hi - lo) / 2under contest pressure — I trust the snippet that I tested once and reuse forever. This is the same principle as using library functions instead of hand-rolled implementations. - Measurement: after implementing snippets for my top 5 recurring bugs, my first-submission acceptance rate increased from 55% to 75% over 2 months. Each prevented WA saves 5-15 minutes of debugging, which compounds across a contest to an extra problem solved.
A junior developer says 'I do not need a mistake journal because I learn from my mistakes naturally.' What evidence would you present to change their mind?
A junior developer says 'I do not need a mistake journal because I learn from my mistakes naturally.' What evidence would you present to change their mind?
- The forgetting curve (Ebbinghaus, 1885) shows humans forget approximately 50% of new information within 24 hours and 70% within a week without deliberate review. A mistake made on Saturday is largely forgotten by the following Saturday’s contest. The journal is the review mechanism that prevents this decay.
- Concrete evidence from my own practice: before journaling, I made the integer overflow mistake an average of once per contest for 3 months (12 occurrences). After starting a journal and reviewing it weekly, the same mistake dropped to once per month within 6 weeks. That is a 75% reduction, translating to roughly 10 minutes saved per contest.
- The journal also reveals patterns invisible to unaided memory. You think you struggle with DP, but your journal shows 80% of your DP mistakes are specifically in the base case initialization, not in the recurrence relation. That level of specificity transforms vague “practice more DP” into actionable “drill DP base cases.”
- The opportunity cost argument: each recurring WA costs 10+ minutes in a contest (debugging + penalty time). If journaling eliminates 3 recurring mistakes per contest, that is 30 minutes recovered — often enough for an additional problem. Over 20 contests, that is the equivalent of 10+ additional hours of productive contest time.