Skip to content

vikashkumar016/DSA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

403 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“š Data Structures & Algorithms (DSA)

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.


πŸ“‚ Repository Structure

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

πŸš€ Quick Start: Adding a LeetCode Solution

Using the Automated Script

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

Script Options

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 -

Supported Languages

  • Python (.py) - Default
  • Java (.java)
  • C++ (.cpp)
  • JavaScript (.js)

πŸ“Š LeetCode Statistics

Current Progress

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 -l to update counts.


πŸ“ Workflow

1. Solve on LeetCode

  • Go to LeetCode
  • Solve the problem
  • Test with multiple test cases

2. Add to Repository

./scripts/add-leetcode-solution.sh \
  -n <problem_number> \
  -t "<Problem Title>" \
  -d <Easy|Medium|Hard> \
  -l <language> \
  -g "Tag1,Tag2"

3. Implement Solution

The script creates:

  • LeetCode/{Difficulty}/{number}-{slug}/solution.{ext}
  • LeetCode/{Difficulty}/{number}-{slug}/README.md

Edit these files with your solution and documentation.

4. Complete Documentation

Fill in the README.md with:

  • Problem description (copy from LeetCode)
  • Your approach and algorithm
  • Complexity analysis
  • Test cases
  • Notes and related problems

5. Commit and Push

git add LeetCode/
git commit -m "Add LeetCode #<number>: <Title> (<Difficulty>)"
git push

Or use the -p flag with the script to do this automatically!


🎯 Solution Template Features

Each solution includes:

Code Template

  • Header with problem metadata
  • Time and space complexity placeholders
  • Approach description section
  • Well-structured solution method
  • Test cases section

README Template

  • 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

πŸ€– GitHub Actions Automation

The repository includes a GitHub Actions workflow that:

  1. Validates Structure - Ensures all problems have required files
  2. Counts Problems - Tracks problems by difficulty
  3. Generates Lists - Creates organized problem lists
  4. 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)

πŸ’‘ Best Practices

Before Adding a Solution

  1. βœ… Solve the problem on LeetCode
  2. βœ… Understand time and space complexity
  3. βœ… Test with edge cases
  4. βœ… Consider alternative approaches

When Writing Code

  1. πŸ“ Use meaningful variable names
  2. πŸ’¬ Add comments for complex logic
  3. 🎨 Follow language-specific conventions
  4. πŸ§ͺ Include comprehensive test cases

Documentation

  1. πŸ“– Explain your thought process
  2. πŸ” Document alternative approaches
  3. πŸ“Š Analyze time and space complexity
  4. ⚠️ Note edge cases and constraints

πŸ“ Directory Organization

LeetCode Problems

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

Scripts

The scripts/ directory contains:

  • add-leetcode-solution.sh - Main automation script
  • templates/ - Code and documentation templates

🏷️ Common Problem Categories

  • 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

πŸ“š Learning Resources

Platforms

Study Guides


🀝 Contributing

This is a personal learning repository, but contributions and suggestions are welcome!

To contribute:

  1. Fork the repository
  2. Create a feature branch
  3. Add your solution using the provided scripts
  4. Submit a pull request

πŸ“œ License

This repository is for educational purposes. All LeetCode problems are property of LeetCode LLC.


πŸŽ“ About

This repository is maintained by @vikashkumar016 as part of continuous learning and interview preparation.

Happy Coding! πŸš€


πŸ“ž Contact

For questions or suggestions, please open an issue or reach out via GitHub.


Last Updated: January 2026

About

No description, website, or topics provided.

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •