This repository contains Data Structures and Algorithms (DSA) problems solved in C++, sourced from LeetCode, GeeksforGeeks, and InterviewBit.
Ideal for competitive programming, coding interviews, and DSA mastery.
- It tracks all the code and problem statement from the free DSA course at youtube by Coder Army via Rohit Negi
- Advanced topics Like DP are covered from Take u forward by Striver
- β 100+ Handpicked Questions
- β Topic-wise Categorization
- β Solutions with Explanations
- β Updated regulary.
- β More than one approach to each problems
Example for easy navigation : purple arrow pointing to "Size of Binary Tree" which when clicked , opens the solution of the problem.
Yellow arrow indicates "platform name" , which on clicking ; navigates you to the problem statement tab.
- Basic DSA /Math
- Basic Array Problems
- Sorting Algorithms
- Binary Search
- Matrix Problems
- Strings
- STL
- Pointers
- Recursion
- OOPS
- Linked List
- Stack
- Queue
- Binary Tree
- Graph
- Heap
- Dynamic Programming
This section covers fundamental problems related to arrays.
-
P1 Program showing basic input and output of an array
-
Problem2 Program to get minimum element in the array
-
P3 Program to get minimum element in the array
-
P4 Linear Search in 1-D array
-
P5 Reverse array :-1)using S.C.-O(n) 2) S.C.-O(1) two pointer approach
-
P7 store fibonaci series :- 0,1,1,2,3,5,8,13.... in an array
-
P12 Count number of elements between two given elements in array GfG link
This section includes various sorting algorithms.
-
Basic
-
Different Problems
-
Different Problems II
-
Binary Search Interview Problem
This section focuses on problems related to 2-D array.
-
Basics
- P1 print matrix col wise , row wise , find element by linear search
- Add2Matrix ; Subtract2Matrix
- P3 Printing sum of diagonal elements ; PrintSumEachRow
- P4 Given a Matrix m * n , we have to find the row index with maximum sum
- P5 Reverse each row of matrix
- Smallest Ele , LargestEle
-
2D Array Interview Problems
- Transpose :- gfg
- SpiralMatrix :- Leetcode
- WaveFormI
- RevCol
- SpiralMatrixII :- LeetCode
- PrintDia :- gfg
- PrintDiaII :- gfg
- SnakePattern :- gfg
-
Rotate Matrix
-
Binary Search in Matrix
- Search2DMatrix :- leetcode ; Also solve in log(n)+log(m) -SearchRowColsortedMatrix :- gfg
- Countzerossortedmatrix :- gfg -RowMax1s :- gfg
- BinarySearchDecOrder
-
Important Problems
- FindMissing&RepeatingEle :- gfg
- CountFreqEle :- gfg
- MajorityEle :- leetcode
- Smallestmissingpositiveinteger :- leetcode (Use Modulous)
- BasicOperations
- DefangIpAdd :- LeetCode ; rotateby2 :- gfg ; Pangram :- leetcode ; sort:-gfg
- LongestPalandrone :- leetcode ; sortSentence :- leetcode
- sortVowels :- leetcode ; AddString :- leetcode ; CaseSort:-gfg
- FactOfLargeNo :- gfg ; RomanToInt :- leetcode ; IntToRoman :- RomanToInt :- Leetcode
- Sliding Window :- LongestSubstrWithoutRepeatChar :- Leetcode ; SmallestDistinctWindow :- gfg ; Smallest_window_0_1_2 :-gfg ; Longest_K_UniquecharSubstring :-gfg
- KMP Algorithm :- LargestPrefixSuffix :- gfg ; IndexFirstOccurranceString :- Leetcode ; Search_Pattern :-gfg
- String Hard Problems ; MinCharsMakePallindrone :- gfg ; RepeatedStringMatch:- Leetcode ; MinAppendPalindrome :- IB ; SHortestPallindrome :- Leetcode
This section focuses on standard template library
This section focuses on pointers
- Lec1 Basics about pointers
- Lec2 pointer with array and pointer arthimetic
- Lec3 pointers with char array , function calls , length & palandrone string
- Lec4 double pointers - 7 problems ; copying str
- Lec4_hw lower to upper ,reverse a string , concatenate :-strings & update ,swap values
- Lec5 Memory Management in 1-D array
- Lec6 2-D , 3-D , 4-D Array Memory Allocation and Deallocation
All about function calling itslef repeatedly untill base condition.
-
lec1 iterative vs mutliple function vs recursion ;printNto1(5);printOddNto1(10);printEvenNto1(10);printName("Helloji");
-
lec2 one vs two arguments ; print1toN(10);print10toN(11);tableN(2);
-
lec3 factorial ; sumN ; powerof2 ;sumSqNno ; powerof4 ; leetcode
-
Lec5 Count No of hops :-gfg ; fibonacci :- Leetcode ; GCD :- gfg ; Nth stair :- leetcode ; Print N fibonacci nos :- GFG
-
lec6 printArray ( 3 approaches) ; sum (2 approach) , evensum, product , min , max
-
lec7 CheckPal :-gfg ; CheckVowels ; CountConsonants ; RevStr :-gfg ; toUpper :-gfg ; toLwr :- gfg
-
Recursion_on_Subsquence : - LeetCode ; subset_string.cpp ; generateParenthesis :- LeetCode ; sumsubsequence , alternative:- gfg
-
PerfectSum :-gfg ; repeattargetsum ; hw
-
Permutation :- leetcode ; PermutationString :- gfg
All about objects and classes
- lec1 object vs function approach ; class & obj ; padding ; static vs dynamic allocation
- lec2 constructor & destructor
- lec3 static data member
- lec4 inheritence ,access modifier
- lec5 types of inheritence
- lec6:- Polymorphism ; function Overloading; Opertor Overloading ; Virtual function
- lec7:- Exception Handling ; Basic ; DIvBy0 ; StdException
- lec8 File handling in cpp
-
Basics :- Structure
-
Problem statements:-
- ReverseLinkedList Approach1 ; Approach2 ;Recursive:- leetcode
- Middle of LinkedList Approach1 ; Approach2 :- leetcode
- RemoveNthNodeFromEnd :- leetcode
- RemoveEveryKthNode :- gfg
- RotateLinkedList:- leetcode
- Palindrome :- Leetcode
-
Doubly Linked List
- Insertion : Start/End ; AnyPosInsert
- Convert Array to DLL using Tail : Code
- Insertion using recursion : Code
- Deletion : Start/End ; AnyPosition
- Reverse :- gfg
-
More Problem statements
- Remove duplicate elements from sorted LinkedList : Approach1 ; Approach2 :- gfg
- Remove loop from Linked List: Approach1 ; Approach2 :- gfg
- Intersection Point in Y Shaped Linked List: Approach1 ; Approach2 :- gfg
- Add Number Linked Lists : Approach :- gfg
- Reverse a Linked List in groups of given size: Approach :- gfg
- Reverse a sublist of a linked list: Approach :- gfg
- Multiply two linked lists: Approach :- gfg
- Flattening a Linked List: Approach :- gfg
-
Problems
-
Special stack :- gfg
-
sort a stack :- gfg
-
More Problems
- Next Greater Element Approach1; Approach2; Approach3:- gfg
- Next Smaller Element :- Cn
- stock span Problem :- gfg
- Smallest number on left :- gfg
- Next Greater Element in Circular Array :- gfg
- Asteroid Collision :- gfg
- Baseball Game :- leetcode
- Remove k digits :- gfg
- Next Greater Element :- leetcode
-
Stack Variation
-
Stack Hard
-
Basics
-
Tree Traversal
-
Basic Questions
-
More Questions
-
View Questions
-
Basics
-
Graph Traversal
- BFS:- gfg
- DFS: recursive:- gfg
- DFS: iterative:- gfg
-
Cycle Detection in undirected graph
- climbing stairs solution :- leetcode
- Frog Jump(DP-3) RecursiveSoln ; DPsolution ; Tablesolution ; SpaceOptimisedsolution ; :- Gfg
- Frog Jump with k distances(DP-4) DPsolution ; Tabulation:- Gfg
- Maximum sum of non-adjacent elements (DP 5) Recursive; DP ; Tabulation :- LC
- House Robber (DP 6) Solution :- LC
- Ninja's Training (DP 7) Recursive; DP ; Tabulation; SpaceOptimsed:- Gfg
- Grid Unique Paths : DP on Grids (DP8) Recursive; DP ; Tabulation; SpaceOptimsed:- LC : alternative solution : yt
- Grid Unique Paths 2 (DP 9) DP ; Tabulation; SpaceOptimised :- LC
- Minimum path sum in Grid (DP 10) Recursive; DP ; Tabulation; SpaceOptimsed:- LC
- Minimum path sum in Triangular Grid (DP 11) Recursive; DP ; Tabulation; SpaceOptimsed:- LC
- Minimum/Maximum Falling Path Sum (DP-12) Recursive; DP ; Tabulation; SpaceOptimsed:- LC
- 3-d DP : Ninja and his friends (DP-13) Recursive; DP ; Tabulation; SpaceOptimsed:- Gfg
-
Subset sum equal to target (DP- 14) Recursive; DP ; Tabulation; SpaceOptimsed:- Gfg
-
Partition Equal Subset Sum (DP- 15) Tabulation :- LC
-
Partition Set Into 2 Subsets With Min Absolute Sum Diff (DP- 16) Tabulation ; Alternative:- LC
-
Count Subsets with Sum K (DP - 17) DP ; Tabulation ; spaceOptimised :- Gfg
-
Count Partitions with Given Difference (DP - 18) Recursion ; DP ; Tabulation ; SpaceOptimised :- LC
-
0/1 Knapsack (DP - 19) Recursive ; DP ; Tabulation ; SpaceOptimised :- CN
-
Minimum Coins (DP - 20) Recursive ; DP ; Tabulation ; SpaceOptimised :- LC
-
Target Sum (DP - 21) Tabulation :- LC
-
Coin Change 2 (DP - 22) Recursive ; DP ; Tabulation ; SpaceOptimised :- LC
-
Unbounded Knapsack (DP - 23) Recursive ; DP ; Tabulation ; SpaceOptimised :- Gfg
-
Rod Cutting (DP - 24) Recursive ; DP ; Tabulation ; SpaceOptimised :- Gfg
- Longest Common Subsequence (DP - 25) WithShiftedIndex ; DP ; Tabulation ; SpaceOptimised :- LC
- Print Longest Common Subsequence | (DP - 26) Tabulation :- Gfg
- Longest Common Substring | (DP - 27) Tabulation ; spaceoptimised:- Gfg
- Longest Palindromic Subsequence | (DP-28) Tabulation :- LC
- Minimum insertions to make string palindrome | DP-29 Tabulation :- LC
- Minimum Insertions/Deletions to Convert String | (DP- 30) Tabulation :- LC
- Maximum Rectangle Area with all 1's|(DP-55)
- prereq : Largest Rectangle in Histogram :- LC
- DP :- LC
- Count Square Submatrices with All Ones|(DP-56)
- pascal tree solution :- LC
- pascal tree ii solution :- LC
- Set Matrix Zeros solution :- LC
- next permutaion solution :- LC
- Kadane's Algorithm solution :- LC
- Sort an array of 0's, 1's and 2's solution :- LC
- transpose a matrix solution :- LC
- rotate a matrix solution :- LC
- Merge two sorted arrays without extra space solution :- LC
- Find the duplicate in an array of N+1 integers solution :- LC
Check out the accompanying YouTube channel for video explanations and tutorials: Coder Army
Feel free to contribute by adding new problems, improving existing solutions, or suggesting enhancements. Follow the contribution guidelines for more details.
This project is licensed under the MIT License.