Skip to content

πŸš€ Comprehensive C++ Data Structures & Algorithms repository featuring Dynamic Programming problems, Graph algorithms, Trees, Sorting, and Backtracking implementations with clean, documented code.

License

Notifications You must be signed in to change notification settings

Namann-14/cpp-dsa

Repository files navigation

πŸš€ C++ Data Structures & Algorithms

A comprehensive collection of DSA implementations, competitive programming solutions, and interview preparation materials

C++ Java Algorithm


GitHub stars GitHub forks GitHub issues GitHub pull requests License Contributions Welcome


⭐ If you find this repository helpful, please consider giving it a star! ⭐


πŸ“‹ Table of Contents


🧠 Features

Feature Description
πŸ“Š 40+ DP Problems Complete Dynamic Programming solutions with detailed explanations
πŸ”— Graph Algorithms BFS, DFS, Dijkstra, Bellman-Ford, Floyd-Warshall, Kruskal's, Prim's & more
🌳 Tree Structures Binary Trees, BST, Traversals, and tree-based problems
πŸ”„ Sorting Algorithms Bubble, Selection, Insertion, Merge, Quick Sort implementations
🧩 Backtracking N-Queens, Sudoku Solver, Rat in a Maze
πŸ† Competitive Programming Codeforces solutions organized by difficulty
πŸ“ OOP Concepts Object-Oriented Programming implementations in C++
πŸ” Binary Search Comprehensive binary search patterns and variations

πŸ“¦ Tech Stack

C++ Java GCC VSCode

Languages:

  • C++17 - Primary language for DSA implementations
  • Java - Alternative implementations for select problems

Tools & Environment:

  • G++ Compiler (MinGW/MSYS2 on Windows)
  • Visual Studio Code with C++ extensions
  • Git for version control

πŸ—‚οΈ Folder Structure

cpp-dsa/
β”‚
β”œβ”€β”€ πŸ“ Backtracking/
β”‚   β”œβ”€β”€ N Queens/
β”‚   β”œβ”€β”€ Rat In A Maze/
β”‚   └── Sudoku Solver/
β”‚
β”œβ”€β”€ πŸ“ Binary Trees/
β”‚   └── main code/
β”‚
β”œβ”€β”€ πŸ“ C++ DSA/
β”‚   β”œβ”€β”€ 2D array/
β”‚   β”œβ”€β”€ Binary Search/
β”‚   β”œβ”€β”€ Math DSA/
β”‚   β”œβ”€β”€ OOPS/
β”‚   β”œβ”€β”€ Pointers/
β”‚   β”œβ”€β”€ Sorting/
β”‚   └── Strings/
β”‚
β”œβ”€β”€ πŸ“ Codeforces/
β”‚   β”œβ”€β”€ A/ (Easy)
β”‚   β”œβ”€β”€ B/ (Medium)
β”‚   β”œβ”€β”€ C/ (Hard)
β”‚   └── D/ (Expert)
β”‚
β”œβ”€β”€ πŸ“ Dynamic Programming/
β”‚   β”œβ”€β”€ 0-1 Knapsack Problem/
β”‚   β”œβ”€β”€ Coin Change/
β”‚   β”œβ”€β”€ Climbing Stairs/
β”‚   β”œβ”€β”€ Best Time to Buy and Sell Stock (I-IV)/
β”‚   β”œβ”€β”€ Longest Common Subsequence/
β”‚   β”œβ”€β”€ Longest Increasing Subsequence/
β”‚   β”œβ”€β”€ Edit Distance/
β”‚   └── ... (40+ problems)
β”‚
β”œβ”€β”€ πŸ“ Graphs/
β”‚   β”œβ”€β”€ BFS (Breadth First Search)/
β”‚   β”œβ”€β”€ DFS (Depth First Search)/
β”‚   β”œβ”€β”€ Dijkstra's Algorithm/
β”‚   β”œβ”€β”€ Bellman Ford Algorithm/
β”‚   β”œβ”€β”€ Floyd Warshall Algorithm/
β”‚   β”œβ”€β”€ Kruskal's Algorithm/
β”‚   β”œβ”€β”€ Prim's Algorithm/
β”‚   β”œβ”€β”€ Kosaraju's Algorithm/
β”‚   └── ... (15+ algorithms)
β”‚
β”œβ”€β”€ πŸ“ Hashmap/
β”œβ”€β”€ πŸ“ Heaps (Priority Queue)/
β”œβ”€β”€ πŸ“ Linked List/
β”œβ”€β”€ πŸ“ Recursion/
β”œβ”€β”€ πŸ“ Stack/
β”œβ”€β”€ πŸ“ Striver/
β”œβ”€β”€ πŸ“ Tries/
β”‚
└── πŸ“„ README.md

πŸ›  Installation & Setup

Prerequisites

Make sure you have the following installed on your system:

  • G++ Compiler (C++17 or later)
  • Git
  • Visual Studio Code (recommended)

Step-by-Step Installation

1. Clone the repository

git clone https://github.com/Namann-14/cpp-dsa.git

2. Navigate to the project directory

cd cpp-dsa

3. Open in VS Code (recommended)

code .

Windows Setup (MSYS2/MinGW)

If you don't have G++ installed on Windows:

# Install MSYS2 from https://www.msys2.org/
# Then run in MSYS2 terminal:
pacman -S mingw-w64-ucrt-x86_64-gcc

πŸš€ Running the Code

Method 1: Command Line

# Navigate to the specific problem folder
cd "Dynamic Programming/Coin Change"

# Compile the C++ file
g++ -std=c++17 -o solution main.cpp

# Run the executable
./solution        # Linux/Mac
.\solution.exe    # Windows

Method 2: VS Code Task (Recommended)

  1. Open any .cpp file
  2. Press Ctrl + Shift + B to build
  3. Press F5 to run with debugging

Method 3: Single Command

# Compile and run in one command (Linux/Mac)
g++ -std=c++17 -o output main.cpp && ./output

# Windows PowerShell
g++ -std=c++17 -o output main.cpp; .\output.exe

πŸ“š Topics Covered

πŸ”„ Dynamic Programming (40+ Problems)
Problem Difficulty Status
Fibonacci 🟒 Easy βœ…
Climbing Stairs 🟒 Easy βœ…
Coin Change 🟑 Medium βœ…
0/1 Knapsack 🟑 Medium βœ…
Longest Common Subsequence 🟑 Medium βœ…
Longest Increasing Subsequence 🟑 Medium βœ…
Edit Distance 🟑 Medium βœ…
Best Time to Buy and Sell Stock (I-IV) 🟑 Medium βœ…
Partition Equal Subset Sum 🟑 Medium βœ…
Perfect Squares 🟑 Medium βœ…
Unique Binary Search Trees 🟑 Medium βœ…
House Robbery Problem 🟑 Medium βœ…
Russian Doll Envelopes πŸ”΄ Hard βœ…
Pizza With 3n Slices πŸ”΄ Hard βœ…
Maximum Height By Stacking Cuboids πŸ”΄ Hard βœ…
And many more...
πŸ”— Graph Algorithms (15+ Algorithms)
Algorithm Type Status
BFS (Breadth First Search) Traversal βœ…
DFS (Depth First Search) Traversal βœ…
Dijkstra's Algorithm Shortest Path βœ…
Bellman-Ford Algorithm Shortest Path βœ…
Floyd-Warshall Algorithm All Pairs Shortest Path βœ…
Kruskal's Algorithm MST βœ…
Prim's Algorithm MST βœ…
Kosaraju's Algorithm Strongly Connected Components βœ…
Cycle Detection (Directed) Utility βœ…
Cycle Detection (Undirected) Utility βœ…
Topological Sort DAG βœ…
Flood Fill Grid βœ…
Bridges in Graph Advanced βœ…
Articulation Points Advanced βœ…
Negative Weight Cycle Detection βœ…
🌳 Trees & Binary Search
  • Binary Tree Traversals (Inorder, Preorder, Postorder)
  • Binary Search variations
  • BST operations
  • Tree construction from traversals
🧩 Backtracking
  • N-Queens Problem
  • Sudoku Solver
  • Rat in a Maze
  • Combination/Permutation problems
πŸ“Š Sorting Algorithms
  • Bubble Sort
  • Selection Sort
  • Insertion Sort
  • Merge Sort
  • Quick Sort
πŸ† Competitive Programming (Codeforces)

Solutions organized by difficulty:

  • Division A - Easy problems
  • Division B - Medium problems
  • Division C - Hard problems
  • Division D - Expert problems

πŸ›£ Roadmap

Completed βœ…

  • Dynamic Programming (40+ problems)
  • Graph Algorithms (15+ algorithms)
  • Backtracking Problems
  • Sorting Algorithms
  • Binary Search Patterns
  • OOP Concepts in C++
  • Codeforces Problems

In Progress 🚧

  • Segment Trees & Fenwick Trees
  • Advanced String Algorithms (KMP, Z-Algorithm, Rabin-Karp)
  • More Codeforces Problems
  • Detailed problem explanations and comments

Planned πŸ“‹

  • Video explanations for complex problems
  • Time & Space complexity analysis for each solution
  • Multiple approaches for each problem
  • Interview preparation guide
  • LeetCode problem solutions (organized by company tags)

🀝 Contributing

Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated!

How to Contribute

  1. Fork the Project

    # Click the 'Fork' button at the top right of this page
  2. Clone your Fork

    git clone https://github.com/YOUR_USERNAME/cpp-dsa.git
  3. Create your Feature Branch

    git checkout -b feature/AmazingFeature
  4. Add your Changes

    git add .
  5. Commit your Changes

    git commit -m "Add: Solution for Problem XYZ"
  6. Push to the Branch

    git push origin feature/AmazingFeature
  7. Open a Pull Request

Contribution Guidelines

  • πŸ“ Add comments explaining the approach
  • 🏷️ Follow the existing folder structure
  • βœ… Test your code before submitting
  • πŸ“Š Include time and space complexity if possible
  • πŸ”— Add problem links in comments

What You Can Contribute

  • πŸ†• New problem solutions
  • πŸ› Bug fixes in existing solutions
  • πŸ“– Documentation improvements
  • ⚑ Code optimizations
  • πŸ§ͺ Alternative approaches

⭐ Support

If this repository helped you in your DSA journey, please consider:

Star this repo Fork this repo Follow


Your support motivates me to keep improving this repository!

⭐ Star = Bookmark for later
🍴 Fork = Create your own copy
πŸ‘€ Follow = Stay updated with my projects


πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

MIT License

Copyright (c) 2024 Naman

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.

Made with ❀️ by Naman


Happy Coding! πŸš€


GitHub


If you found this helpful, don't forget to ⭐ star the repository!

About

πŸš€ Comprehensive C++ Data Structures & Algorithms repository featuring Dynamic Programming problems, Graph algorithms, Trees, Sorting, and Backtracking implementations with clean, documented code.

Topics

Resources

License

Stars

Watchers

Forks

Languages