A comprehensive collection of DSA implementations, competitive programming solutions, and interview preparation materials
β If you find this repository helpful, please consider giving it a star! β
- π§ Features
- π¦ Tech Stack
- ποΈ Folder Structure
- π Installation & Setup
- π Running the Code
- π Topics Covered
- π£ Roadmap
- π€ Contributing
- β Support
- π License
| 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 |
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
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
Make sure you have the following installed on your system:
- G++ Compiler (C++17 or later)
- Git
- Visual Studio Code (recommended)
1. Clone the repository
git clone https://github.com/Namann-14/cpp-dsa.git2. Navigate to the project directory
cd cpp-dsa3. Open in VS Code (recommended)
code .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# 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- Open any
.cppfile - Press
Ctrl + Shift + Bto build - Press
F5to run with debugging
# 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π 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
- Dynamic Programming (40+ problems)
- Graph Algorithms (15+ algorithms)
- Backtracking Problems
- Sorting Algorithms
- Binary Search Patterns
- OOP Concepts in C++
- Codeforces Problems
- Segment Trees & Fenwick Trees
- Advanced String Algorithms (KMP, Z-Algorithm, Rabin-Karp)
- More Codeforces Problems
- Detailed problem explanations and comments
- 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)
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated!
-
Fork the Project
# Click the 'Fork' button at the top right of this page -
Clone your Fork
git clone https://github.com/YOUR_USERNAME/cpp-dsa.git
-
Create your Feature Branch
git checkout -b feature/AmazingFeature
-
Add your Changes
git add . -
Commit your Changes
git commit -m "Add: Solution for Problem XYZ" -
Push to the Branch
git push origin feature/AmazingFeature
-
Open a Pull Request
- π 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
- π New problem solutions
- π Bug fixes in existing solutions
- π Documentation improvements
- β‘ Code optimizations
- π§ͺ Alternative approaches
Your support motivates me to keep improving this repository!
β Star = Bookmark for later
π΄ Fork = Create your own copy
π€ Follow = Stay updated with my projects
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! π
If you found this helpful, don't forget to β star the repository!