This document provides comprehensive guidance on using the automation scripts in this LeetCode solutions repository.
- Overview
- Scripts Overview
- Installation & Setup
- create_missing_notes.sh
- update_difficulties.sh
- Workflow Examples
- File Structure
- Troubleshooting
- Advanced Usage
This repository contains two powerful automation scripts designed to streamline your LeetCode learning journey:
create_missing_notes.sh- Automatically generates structured note templates for solved problemsupdate_difficulties.sh- Manages problem difficulty mappings dynamically
These scripts help maintain a professional, well-organized repository with proper documentation, badges, and links.
| Script | Purpose | Key Features |
|---|---|---|
create_missing_notes.sh |
Generate note templates | • Auto-detects solved problems • Creates structured markdown notes • Includes badges and links • Skips existing files |
update_difficulties.sh |
Manage difficulty mappings | • Add/remove difficulty mappings • Update all note files • List current mappings • Dynamic difficulty management |
- Bash shell (macOS, Linux, or WSL on Windows)
- Git repository with LeetCode solutions
-
Ensure scripts are executable:
chmod +x create_missing_notes.sh chmod +x update_difficulties.sh
-
Verify your directory structure:
leetcode/ ├── src/ │ ├── exercises/ # Your Python solutions │ └── notes/ # Generated notes (created automatically) ├── create_missing_notes.sh ├── update_difficulties.sh └── SCRIPTS_DOCUMENTATION.md
Automatically generates structured markdown note files for all solved problems that don't have notes yet.
./create_missing_notes.sh- Scans
src/exercises/directory for Python solution files - Extracts problem numbers and titles from filenames
- Creates corresponding note files in
src/notes/with:- Professional badges and shields
- Links to LeetCode problems
- Structured sections for learning notes
- Navigation links
- Skips files that already have notes
Each note file includes:
- Header with problem title and badges
- Problem metadata (number, difficulty, category, LeetCode link)
- Learning sections:
- Problem Description
- My Approach
- Solution
- Time & Space Complexity
- Key Insights
- Mistakes Made
- Related Problems
- Navigation links back to index and solution
🧠 Scanning exercises directory and generating missing LeetCode problem notes...
✅ Created: src/notes/001_two_sum.md
⏭️ Skipped: src/notes/002_add_two_numbers.md (already exists)
✅ Created: src/notes/003_longest_substring_without_repeating_characters.md
🎉 Note generation complete!
📝 Files processed: 95
✅ New notes created: 15
⏭️ Notes skipped (already exist): 80
📁 Notes directory: src/notes
Manages problem difficulty mappings dynamically without hardcoding, and updates note files accordingly.
./update_difficulties.sh -a <problem_number> <difficulty>Examples:
./update_difficulties.sh -a 1 Easy
./update_difficulties.sh -a 4 Hard
./update_difficulties.sh -a 15 Medium./update_difficulties.sh -r <problem_number>Example:
./update_difficulties.sh -r 1./update_difficulties.sh -lOutput:
📋 Current Difficulty Mappings:
Problem | Difficulty
--------|-----------
1 | Easy
2 | Medium
4 | Hard
15 | Medium
./update_difficulties.sh -uUpdates all note files to reflect correct difficulties from the mapping file.
./update_difficulties.sh -hThe script creates and manages a .difficulty_mapping file:
1:Easy
2:Medium
4:Hard
15:Medium
When you solve a new problem:
# 1. Add your solution to src/exercises/
# 2. Generate note template
./create_missing_notes.sh
# 3. Add correct difficulty
./update_difficulties.sh -a 42 Hard
# 4. Update all notes with correct difficulties
./update_difficulties.sh -u
# 5. Edit the generated note with your insights
# File: src/notes/042_trapping_rain_water.mdProcess multiple problems at once:
# Generate notes for all solved problems
./create_missing_notes.sh
# Add difficulties for multiple problems
./update_difficulties.sh -a 1 Easy
./update_difficulties.sh -a 2 Medium
./update_difficulties.sh -a 4 Hard
./update_difficulties.sh -a 15 Medium
# Update all notes
./update_difficulties.sh -uRegular maintenance tasks:
# Check current difficulty mappings
./update_difficulties.sh -l
# Remove incorrect mapping
./update_difficulties.sh -r 1
# Add correct mapping
./update_difficulties.sh -a 1 Easy
# Update all notes
./update_difficulties.sh -uAfter running the scripts, your repository will have this structure:
leetcode/
├── src/
│ ├── exercises/
│ │ ├── 1.two-sum.py
│ │ ├── 2.add-two-numbers.py
│ │ └── ...
│ └── notes/
│ ├── 001_two_sum.md
│ ├── 002_add_two_numbers.md
│ └── ...
├── .difficulty_mapping # Created by update_difficulties.sh
├── create_missing_notes.sh
├── update_difficulties.sh
├── SCRIPTS_DOCUMENTATION.md
└── README.md
# Two Sum
[](https://leetcode.com/problems/two-sum/)
[](https://leetcode.com/problemset/?difficulty=EASY)
[](https://leetcode.com/problems/two-sum/)
**Problem Number:** [1](https://leetcode.com/problems/two-sum/)
**Difficulty:** [Easy](https://leetcode.com/problemset/?difficulty=EASY)
**Category:**
**LeetCode Link:** [https://leetcode.com/problems/two-sum/](https://leetcode.com/problems/two-sum/)
## Problem Description
> **View the full problem description on LeetCode:** [Two Sum](https://leetcode.com/problems/two-sum/)
## My Approach
## Solution
## Time & Space Complexity
## Key Insights
## Mistakes Made
## Related Problems
---
[](../../README.md#-problem-index) | [](../exercises/1.two-sum.py)
*Note: This is a work in progress. I'll add more details as I reflect on this problem.*chmod +x create_missing_notes.sh
chmod +x update_difficulties.shThe script automatically creates the src/notes/ directory if it doesn't exist.
Valid difficulties are: Easy, Medium, Hard (case-sensitive)
Ensure your Python solution files follow the naming convention: number.problem-name.py
| Error | Cause | Solution |
|---|---|---|
❌ Error: Invalid difficulty |
Wrong difficulty format | Use: Easy, Medium, or Hard |
⚠️ Skipped empty file |
Empty solution file | Add solution code |
⚠️ Skipped invalid filename |
Wrong file naming | Use: number.problem-name.py |
Edit the create_note_file() function in create_missing_notes.sh to customize note structure.
Create a script to update multiple difficulties:
#!/bin/bash
# batch_update_difficulties.sh
difficulties=(
"1:Easy"
"2:Medium"
"4:Hard"
"15:Medium"
)
for mapping in "${difficulties[@]}"; do
problem_num=$(echo $mapping | cut -d':' -f1)
difficulty=$(echo $mapping | cut -d':' -f2)
./update_difficulties.sh -a $problem_num $difficulty
done
./update_difficulties.sh -uAdd to your workflow:
# After solving a problem
./create_missing_notes.sh
./update_difficulties.sh -a <problem_number> <difficulty>
./update_difficulties.sh -u
git add .
git commit -m "Add solution and notes for problem <number>"- Run
create_missing_notes.shafter solving new problems - Update difficulties as you learn them
- Use
-uflag to keep all notes synchronized - Edit generated notes with your personal insights
- Commit changes regularly to track your progress
To improve these scripts:
- Test changes thoroughly
- Update this documentation
- Follow the existing code style
- Add error handling for edge cases
Happy Coding! 🎉
These scripts are designed to make your LeetCode learning journey more organized and professional.