Welcome to my DSA repository! This repository contains a comprehensive collection of data structures and algorithm problems, solutions, and notes. It's meant for practice, learning, and interview preparation.
DSA/
βββ LeetCode/ # Organized LeetCode solutions by difficulty
β βββ Easy/ # Easy difficulty problems
β βββ Medium/ # Medium difficulty problems
β βββ Hard/ # Hard difficulty problems
β βββ README.md # LeetCode section documentation
βββ scripts/ # Automation scripts
β βββ add-leetcode-solution.sh # Script to add new LeetCode solutions
β βββ templates/ # Solution and README templates
β βββ solution-template.py
β βββ solution-template.java
β βββ solution-template.cpp
β βββ solution-template.js
β βββ problem-readme-template.md
βββ .github/
β βββ workflows/
β βββ leetcode-sync.yml # GitHub Actions workflow
βββ README.md # This file
The easiest way to add a new LeetCode solution is using the provided script:
# Navigate to repository root
cd /path/to/DSA
# Add a new solution
./scripts/add-leetcode-solution.sh -n <number> -t "<title>" -d <difficulty> -l <language>Example:
# Add "Two Sum" in Python
./scripts/add-leetcode-solution.sh -n 1 -t "Two Sum" -d Easy -l python -g "Array,Hash Table"
# Add and auto-commit
./scripts/add-leetcode-solution.sh -n 15 -t "3Sum" -d Medium -l java -g "Array,Two Pointers" -c
# Add, commit, and push
./scripts/add-leetcode-solution.sh -n 4 -t "Median of Two Sorted Arrays" -d Hard -l cpp -p| Option | Description | Required | Default |
|---|---|---|---|
-n, --number |
Problem number | Yes | - |
-t, --title |
Problem title | Yes | - |
-d, --difficulty |
Easy, Medium, or Hard | Yes | - |
-l, --language |
python, java, cpp, js | No | python |
-s, --slug |
URL slug | No | Auto-generated |
-g, --tags |
Comma-separated tags | No | TODO |
-c, --commit |
Auto-commit changes | No | false |
-p, --push |
Auto-commit and push | No | false |
-h, --help |
Display help | No | - |
- Python (.py) - Default
- Java (.java)
- C++ (.cpp)
- JavaScript (.js)
| Difficulty | Count |
|---|---|
| π’ Easy | 0 |
| π‘ Medium | 0 |
| π΄ Hard | 0 |
| Total | 0 |
Run the GitHub Actions workflow or use
find LeetCode/{Easy,Medium,Hard} -mindepth 1 -maxdepth 1 -type d | wc -lto update counts.
- Go to LeetCode
- Solve the problem
- Test with multiple test cases
./scripts/add-leetcode-solution.sh \
-n <problem_number> \
-t "<Problem Title>" \
-d <Easy|Medium|Hard> \
-l <language> \
-g "Tag1,Tag2"The script creates:
LeetCode/{Difficulty}/{number}-{slug}/solution.{ext}LeetCode/{Difficulty}/{number}-{slug}/README.md
Edit these files with your solution and documentation.
Fill in the README.md with:
- Problem description (copy from LeetCode)
- Your approach and algorithm
- Complexity analysis
- Test cases
- Notes and related problems
git add LeetCode/
git commit -m "Add LeetCode #<number>: <Title> (<Difficulty>)"
git pushOr use the -p flag with the script to do this automatically!
Each solution includes:
- Header with problem metadata
- Time and space complexity placeholders
- Approach description section
- Well-structured solution method
- Test cases section
- Problem description
- Approach explanation
- Step-by-step algorithm
- Complexity analysis with explanations
- Multiple solution approaches
- Test cases with expected outputs
- Notes and tips
- Related problems
The repository includes a GitHub Actions workflow that:
- Validates Structure - Ensures all problems have required files
- Counts Problems - Tracks problems by difficulty
- Generates Lists - Creates organized problem lists
- Updates Statistics - Keeps README stats current (optional)
Workflow runs on:
- Push to main branch (when LeetCode files change)
- Manual trigger via GitHub Actions UI
- Scheduled daily updates (optional, can be enabled)
- β Solve the problem on LeetCode
- β Understand time and space complexity
- β Test with edge cases
- β Consider alternative approaches
- π Use meaningful variable names
- π¬ Add comments for complex logic
- π¨ Follow language-specific conventions
- π§ͺ Include comprehensive test cases
- π Explain your thought process
- π Document alternative approaches
- π Analyze time and space complexity
β οΈ Note edge cases and constraints
Organized by difficulty in the LeetCode/ directory:
- Easy/ - Foundational problems, basic algorithms
- Medium/ - Common interview problems, intermediate concepts
- Hard/ - Advanced algorithms, complex data structures
Each problem follows the structure:
{number}-{slug}/
βββ solution.{ext} # Your solution code
βββ README.md # Problem documentation
The scripts/ directory contains:
add-leetcode-solution.sh- Main automation scripttemplates/- Code and documentation templates
- Arrays & Strings: Manipulation, searching, sorting
- Linked Lists: Traversal, reversal, cycle detection
- Trees & Graphs: Traversal (DFS/BFS), searching
- Dynamic Programming: Memoization, tabulation
- Greedy Algorithms: Optimization problems
- Backtracking: Permutations, combinations
- Binary Search: Searching, optimization
- Two Pointers: Array problems, string problems
- Sliding Window: Subarray problems
- Hash Tables: Fast lookups, counting
- LeetCode - Practice platform
- NeetCode - Curated problem lists
- LeetCode Patterns - Common patterns
This is a personal learning repository, but contributions and suggestions are welcome!
To contribute:
- Fork the repository
- Create a feature branch
- Add your solution using the provided scripts
- Submit a pull request
This repository is for educational purposes. All LeetCode problems are property of LeetCode LLC.
This repository is maintained by @vikashkumar016 as part of continuous learning and interview preparation.
Happy Coding! π
For questions or suggestions, please open an issue or reach out via GitHub.
Last Updated: January 2026