LearnCPP
LearnCPP copied to clipboard
Learn Cpp from Beginner to Advanced โ Practice ๐ฏ Code ๐ป Repeat ๐ One step solution for c++ beginners and cp enthusiasts.
Some Helpful Resources
| CppNuts | Codecademy | Leetcode |
| The Cherno | johnmcfarlane/begin(C++) | HackerRank |
| ChiliTomatoNoodle | ratansingh98/CPP-Learning | CodeChef |
| Bo Qian | sahilbansal17/Get_Better_at_CP_in_2_Months | CodeForces |
| CodeBlocks | Visualisze algorithms through animations | Learn CPP |
| VS Code | CP Algorithms | CF Blog : Resources for cpp |
What's Inside ๐
- Advanced Data Structures
- Array
- Backtracking
- Bit Manipulation
- Disjoint Set Union
- Divide And Conquer Algorithms
- Dynamic Programming
- Extra
- Graph Algorithms
- Graphs
- Greedy Algorithms
- HashMap
- HashTable
- Heap
- Linked List
- Mathematical Algorithms
- Miscellaneous
- Priority Queue
- Problem Statements and Solution
- Queue
- Recursion
- STL
- Searching Algorithms
- Sets
- Sorting Algorithms
- Stack
- String Algorithms
- Strings
- Template
- Tree
- Trie
Read the following steps before contributing.
| Follow Steps | Get Started |
|---|---|
![]() |
![]() |
![]() |
![]() |
Algorithms
| Follow these steps | |
|---|---|
| New Algorithm | 'Please see if the algorithm is already present' |
| What to include | "Your algorithm should be efficiently written with proper code / comments / time complexity / space complexity / link to gfg or any other documentation on top in code file" |
| Where to include | please commit your algorithm in the correct folder or discuss[here](https://github.com/Lakhankumawat/LearnCPP/discussions/7)before committing to where to include` |
| README | "Please check whether your directory has a README file, if there is then edit your algorithm name with a link, otherwise create a new one " how your README should look like |
Problem Statement
| Follow these steps | |
|---|---|
| New Problem Statement | 'Please see if the problem is present already? If it is do not commit your own ' |
| What to include | "Your problem statement solution should be efficiently written with proper code / comments / time complexity / space complexity / link to problem statement in code file" |
| Where to include | Most of the Problem Statements are insidehereplease commit your problem solution in the correct folder or discuss here before committing for where to include |
| README | "Please check whether your directory has a README file, if there is then edit your algorithm name with a link, otherwise create a new one " how your README should look like |
| Additional Context | "There are three levels of problem statement" 1-Level 1 `likewise 2-Level 2 & 3-Level 3, please include your problem statement with a solution in the right level you prefer |
To add programs using STL, follow the same approach as Algorithms
Readme
Fond of designing README this section will be helpful to you
| Follow these steps | |
|---|---|
| ๐ New README | 'Please see if there is no README in any folder if no? Then please design it, if yes? Then please edit it accordingly to your contribution and follow the guidelines ' |
| ๐ค What to include | "Your README should be efficiently and written / link to problem statement in README at the top" see exmaple |
| โ Must Contain | 1. and explain in brief about addition 2. An Image of addition i.e how it works 3. Mention the Pseudo Code 4. Time and Space Complexities 5. Advantages 6. Disadvantages |
| ๐ชง Where to include | Inside the folder where programs are residing, discuss here before committing to where to include |
Why contribute?
- If you find any errors or bugs then please report them by creating an issue.
- If you can provide a more efficient solution or implementation of the algorithm then make sure to contribute.
- If you want to implement an algorithm, data structure etc.., which is not yet there, then you can open up a PR regarding the same.
- Link to discussion forum
Want to contribute?
- Take a look at
contributing guidelinesif you're interested in helping! - Refer GitHub Flow.
๐ Stargazers Over Time ๐
Project Maintainers โค๏ธ
LakhanKumawat แตโบ ๐ป ๐ ๐ |
Nikita Sharma ๐ป ๐ ๐ง |
SK MIRAJ ๐ป ๐ ๐ง |
Gunjan ๐ป ๐ ๐ง |
Siddhi Bhanushali ๐ป ๐ ๐ง |
Pooja Mangal ๐ |
TRIDIB BAG ๐ |
Aditi ๐ |
Vilsi Jain ๐ |
-
Array
| # | Problem Statement & Explanation | Solution |
|---|---|---|
| 1 | Array Operations | Solution |
| 2 | Antispiral Matrix | Solution |
| 3 | Counting Divisibl eSubstrings | Solution |
| 4 | First Negative in Every Window | Solution |
| 5 | Maximum Sum Subarray | Solution |
| 6 | Missing and Repeating Number | Solution |
| 7 | Peak in 1D Array | Solution |
| 8 | Prefix Sum | Solution |
| 9 | Reversing of Array | Solution |
| 10 | Sort an Array of 0's 1's and 2's | Solution |
| 11 | Best Time to Buy and Sell Stock | Solution |
| 12 | Symmetric Matrix | Solution |
| 13 | Trace and Normal | Solution |
-
Backtracking
| # | Problem Statement & Explanation | Solution |
|---|---|---|
| 1 | Hamiltonian Cycle | Solution |
| 2 | N-Queen | Solution |
| 3 | Rat in Maze | Solution |
| 4 | Subset Sum | Solution |
| 5 | The Knightโs Tour Problem | Solution |
-
Bit Manipulation
| # | Problem Statement & Explanation | Solution |
|---|---|---|
| 1 | Bit Manipulation | Solution |
| 2 | Cout Set Bits | Solution |
| 3 | Swapping 2 Numbers | Solution |
-
Disjoint Set Union
| # | Problem Statement & Explanation | Solution |
|---|---|---|
| 1 | Disjoint Set Union | Solution |
-
Dynamic Programming
| # | Problem Statement & Explanation | Solution |
|---|---|---|
| 1 | Rod Cutting | Solution |
| 2 | Equal Sum Partition Problem | Solution |
| 3 | Shortest Common Super-sequence | Solution |
| 4 | Trapping Rain Water Problem | Solution |
| 5 | Longest Common Subsequence Problem | Solution |
| 6 | Egg Dropping Puzzle | Solution |
| 7 | Climbing Stairs | Solution |
| 8 | Min Cost Climbing Stairs | Solution |
| 9 | Unique Paths | Solution |
| 10 | Unique Paths II | Solution |
| 11 | Minimum Falling Path Sum | Solution |
| 12 | Knapsack with Duplicate Items | Solution |
| 13 | Minimum number of deletions and insertions required | Solution |
| 14 | Coin Change | Solution |
| 15 | Kadane's Algorithm | Solution |
| 16 | 0-1 KnapSack | Solution |
| 17 | Traveling Sales Person | Solution |
| 18 | Subset Sum | Solution |
| 19 | Minimun Insertions form Palindrome | Solution |
-
Extra
| # | Problem Statement & Explanation | Solution |
|---|---|---|
| 1 | Turtle | Solution |
| 2 | Projectile | Solution |
| 3 | Design | Solution |
-
Graph Algorithms
| # | Problem Statement & Explanation | Solution |
|---|---|---|
| 1 | Multistage Graph Shortest Path | Solution |
| 2 | Bellman Ford | Solution |
| 3 | Floyd Warshall | Solution |
| 4 | Dijsktra Single Source Shortest Path | Solution |
-
Graphs
| # | Problem Statement & Explanation | Solution |
|---|---|---|
| 1 | Articulation Points | Solution |
| 2 | Graph Coloring | Solution |
| 3 | Check Bipartite | Solution |
| 4 | Add and delete edge of directed graph in an adjacency matrix | Solution |
| 5 | create and display an adjacency matrix | Solution |
| 6 | Adjacency List | Solution |
| 7 | Adjacency List Using Hashmap | Solution |
| 8 | Prims | Solution |
| 9 | Prims using Priority Queue | Solution |
| 10 | Kruskal | Solution |
| 11 | kruskal DSU | Solution |
| 12 | Ford Fulkerson | Solution |
| 13 | Breadth First Search | Solution |
| 14 | Depth First Search | Solution |
-
Greedy Algorithms
| # | Problem Statement & Explanation | Solution |
|---|---|---|
| 1 | Optimal Merge Pattern | Solution |
| 2 | Huffman Coding | Solution |
| 3 | Fractional KnapSack | Solution |
| 4 | Job Scheduling | Solution |
| 5 | Busyman Problem | Solution |
-
HashMap
| # | Problem Statement & Explanation | Solution |
|---|---|---|
| 1 | HashMaps | Solution |
| 2 | Map | Solution |
| 3 | Multimap | Solution |
| 4 | UnorderedMap | Solution |
| 5 | UnorderedMaps CustomHashmaps OperatorOverloading | Solution |
| 6 | Set | Solution |
| 7 | Unordered Set | Solution |
-
Heap
| # | Problem Statement & Explanation | Solution |
|---|---|---|
| 1 | k largest | Solution |
| 2 | Min Heap | Solution |
| 3 | Max Heap | Solution |
| 4 | Heapify | Solution |
| 5 | Heap Sort | Solution |
-
Linked List
| # | Problem Statement & Explanation | Solution |
|---|---|---|
| 1 | Singly Linked List | Solution |
| 2 | Removing Duplicates | Solution |
| 3 | Searching in a linked list | Solution |
| 4 | Reverse a Linked List | Solution |
| 5 | Middle element of the linked list | Solution |
| 6 | Palindrome linked list | Solution |
| 7 | Segregate Even Odd | Solution |
| 8 | Merge K Sorted LinkedList | Solution |
| 9 | LRU Cache | Solution |
| 10 | Circular Linked Lists | Explanation |
| 11 | Reverse a Doubly Linked List | Solution |
-
Mathematical Algorithms
| # | Problem Statement & Explanation | Solution |
|---|---|---|
| 1 | SegmentedSieve | Solution |
| 2 | Armstrong number | Solution |
| 3 | Eulid Greatest Common Divisor | Solution |
| 4 | Prime Sum | Solution |
| 5 | Factorial Larger Numbers | Solution |
| 6 | Juggler Sequence | Solution |
-
Miscellaneous
| # | Problem Statement & Explanation | Solution |
|---|---|---|
| 1 | Exception Handling | Solution |
| 2 | Lambda Functions | Solution |
| 3 | Friend Class | Solution |
| 4 | Friend Function | Solution |
-
Priority Queue
| # | Problem Statement & Explanation | Solution |
|---|---|---|
| 1 | Priority Queue | Solution |
| 2 | Priority Queue STL Comparator | Solution |
-
Problem Statements and Solution
| # | Problem Statement & Explanation | Solution |
|---|---|---|
| 1 | Aggressive Cows | Solution |
| 2 | Pair with given sum in sorted doubly linked list | Solution |
| 3 | Maximum of all Subarrays of size k | Solution |
| 4 | Lowercase to Uppercase | Solution |
| 5 | Counting Frequencies | Solution |
-
Queue
| # | Problem Statement & Explanation | Solution |
|---|---|---|
| 1 | Queue Using Linked List | Solution |
| 2 | Queue Using Array | Solution |
| 3 | [Queue STL] | Solution |
| 4 | Circular Queue Using LinkedList | Solution |
| 5 | Reverse Queue | Solution |
| 6 | Circular Queue Using Array | Solution |
-
Recursion
| # | Problem Statement & Explanation | Solution |
|---|---|---|
| 1 | Inversion Count | Solution |
| 2 | Replace PI | Solution |
| 3 | Tower of Hanoi | Solution |
| 4 | Calculating GCD and LCM by Recursion | Solution |
| 5 | Taylor series by Horner's rule | Solution |
| 6 | Types of Recursion | Solution |
-
STL
| # | Problem Statement & Explanation | Solution |
|---|---|---|
| 1 | Pairs STL | Solution |
| 2 | Lists-Operation | Solution |
| 3 | Lists | Solution |
| 4 | Multiset | Solution |
| 5 | Sets | Solution |
| 6 | Vector | Solution |
-
Searching Algorithms
| # | Problem Statement & Explanation | Solution |
|---|---|---|
| 1 | Linear Search | Solution |
| 2 | Binary Search | Solution |
| 3 | Search Element in a Rotated Sorted Array | Solution |
-
Sets
| # | Problem Statement & Explanation | Solution |
|---|---|---|
| 1 | Cartesian Product of two Set | Solution |
| 2 | Union of two sets | Solution |
-
Sorting Algorithms
| # | Problem Statement & Explanation | Solution |
|---|---|---|
| 1 | Bubble Sort | Solution |
| 2 | Insertion Sort | Solution |
| 3 | Quick Sort | Solution |
| 4 | Merge Sort | Solution |
| 5 | Counting Sort | Solution |
| 6 | Bucket Sort | Solution |
| 7 | DNF Sort | Solution |
| 8 | Selection Sort | Solution |
-
Stack
| # | Problem Statement & Explanation | Solution |
|---|---|---|
| 1 | Infix to postfix conversion | Solution |
| 2 | Redundant Parenthesis | Solution |
| 3 | Stack ADT using Linked List | Solution |
| 4 | Converting decimal number to binary | Solution |
| 5 | Stacks Without STL | Solution |
| 6 | Stacks STL | Solution |
| 7 | Next Greater Element | Solution |
| 8 | Bracket Balancing Using Stack | Solution |
-
String Algorithms
| # | Problem Statement & Explanation | Solution |
|---|---|---|
| 1 | KMP | Solution |
-
Strings
| # | Problem Statement & Explanation | Solution |
|---|---|---|
| 1 | Strings | Solution |
| 2 | String Toknizer | Solution |
| 3 | String Sorting | Solution |
| 4 | String Reverse | Solution |
| 5 | String Comparison | Solution |
| 6 | Longest Word In Sentence | Solution |
| 7 | String Palindrome | Solution |
-
Template
| # | Problem Statement & Explanation | Solution |
|---|---|---|
| 1 | Class Template | Solution |
| 2 | Function Template | Solution |
-
Tree
| # | Problem Statement & Explanation | Solution |
|---|---|---|
| 1 | Ceil Value in BST | Solution |
| 2 | Check Valid BST | Solution |
| 3 | Floor Value in BST | Solution |
| 4 | BST | Solution |
| 5 | AVL | Solution |
| 6 | Array to Bst | Solution |
| 7 | Construct BST From Preorder Travsersal | Solution |
| 8 | Height of the binary tree | Solution |
| 9 | Largest Bst in a Binary Tree | Solution |
| 10 | Diameter of Binary Tree | Solution |
| 11 | Number of leaf nodes in binary tree | Solution |
| 12 | FenwickTree | Solution |
| 13 | Iterative Preorder and Postorder Traversal of Generic Tree | Solution |
| 14 | Level order traversal in a Genric Tree | Solution |
| 15 | Mirror of a Genric Tree | Solution |
| 16 | Diameter of a Genric Tree | Solution |
| 17 | Minimum distance between two nodes in a Genric Tree | Solution |
| 18 | Construct and Display Genric Tree | Solution |
| 19 | Diagonal Traversal | Solution |
| 20 | Morris Traversal | Solution |
| 21 | Preorder Traversal | Solution |
| 22 | Postorder Traversal | Solution |
| 23 | Inorder Traversal | Solution |
| 24 | Levelorder Traversal | Solution |
Contributors โจ
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind are welcome!
Happy Coding !!
ยฉ LearnCPP 2022
All Rights Reserved
Developed with โค๏ธ in India ๐ฎ๐ณ



