In this repository, I have stored solutions to various problems and concepts of Data Structures and Algorithms in Python3 in a structured manner.

Topics Covered:

In various folders of the above topics, you can find questions and concepts related to that topic.

DSAlgo repo

I am continuously trying to improve this repository by adding new questions and concepts related to the respective topic. Please feel free to contribute to this repository.💻

View this repository with improved user experience▶️https://samirpaul.in/DSAlgo🚀

DSA Online VSCode

Things you can contribute to:

  • Update the existing solution with a better one (better complexity).
  • Add new questions and solutions in Python3 to the respective directory.
  • Add new resources to BOOKS-and-PDFs & Questions-Sheet .
  • Solve issues raised by other people or yourself.
  • Provide well-documented source code with detailed explanations.

List of Important Questions:✨

The following list of questions was recommended by Love Babbar on this video . I have documented all those questions here.✌️

TopicImportant DSA QuestionsLink
Topic:Problem:Related Link
<->
ArrayReverse the array<->
ArrayFind the maximum and minimum element in an array<->
ArrayFind the “Kth” max and min element of an array<->
ArrayGiven an array which consists of only 0, 1 and 2. Sort the array without using any sorting algo<->
ArrayMove all the negative elements to one side of the array<->
ArrayFind the Union and Intersection of the two sorted arrays.<->
ArrayWrite a program to cyclically rotate an array by one.https://leetcode.com/problems/rotate-array/
Arrayfind Largest sum contiguous Subarray [V. IMP]https://leetcode.com/problems/maximum-subarray/
ArrayMinimise the maximum difference between heights [V.IMP]https://leetcode.com/problems/smallest-range-ii/
ArrayMinimum no. of Jumps to reach end of an arrayhttps://leetcode.com/problems/jump-game
Arrayfind duplicate in an array of N+1 Integers<->
ArrayMerge 2 sorted arrays without using Extra space.<->
ArrayKadane’s Algorithmhttps://leetcode.com/problems/maximum-subarray/
ArrayMerge Intervals<->
ArrayNext Permutation<->
ArrayCount Inversion<->
ArrayBest time to buy and Sell stock<->
Arrayfind all pairs on integer array whose sum is equal to given number<->
Arrayfind common elements In 3 sorted arrays<->
ArrayRearrange the array in alternating positive and negative items with O(1) extra space<->
ArrayFind if there is any subarray with sum equal to 0https://leetcode.com/problems/subarray-sum-equals-k/
ArrayFind factorial of a large number<->
Arrayfind maximum product subarray<->
ArrayFind longest coinsecutive subsequence<->
ArrayGiven an array of size n and a number k, fin all elements that appear more than " n/k " times.<->
ArrayMaximum profit by buying and selling a share atmost twice<->
ArrayFind whether an array is a subset of another array<->
ArrayFind the triplet that sum to a given value<->
ArrayTrapping Rain water problem<->
ArrayChocolate Distribution problem<->
ArraySmallest Subarray with sum greater than a given value<->
ArrayThree way partitioning of an array around a given value<->
ArrayMinimum swaps required bring elements less equal K together<->
ArrayMinimum no. of operations required to make an array palindrome<->
ArrayMedian of 2 sorted arrays of equal size<->
ArrayMedian of 2 sorted arrays of different size<->
ArraySubarray Sums Divisible by K
ArrayContinuous Subarray Sum
<->
<->
MatrixSpiral traversal on a Matrix<->
MatrixSearch an element in a matriix<->
MatrixFind median in a row wise sorted matrix<->
MatrixFind row with maximum no. of 1’s<->
MatrixPrint elements in sorted order using row-column wise sorted matrix<->
MatrixLargest Rectangle in Histogram
MatrixMaximum size rectanglehttps://practice.geeksforgeeks.org/problems/max-rectangle/1
MatrixFind a specific pair in matrix<->
MatrixRotate matrix by 90 degrees<->
MatrixKth smallest element in a row-cpumn wise sorted matrix<->
MatrixCommon elements in all rows of a given matrix<->
StringReverse a String<->
StringCheck whether a String is Palindrome or not<->
StringFind Duplicate characters in a string<->
StringWhy strings are immutable in Java?<->
StringWrite a Code to check whether one string is a rotation of another<->
StringWrite a Program to check whether a string is a valid shuffle of two strings or not<->
StringCount and Say problem<->
StringWrite a program to find the longest Palindrome in a string.[ Longest palindromic Substring]<->
StringFind Longest Recurring Subsequence in String<->
StringPrint all Subsequences of a string.<->
StringPrint all the permutations of the given string<->
StringSplit the Binary string into two substring with equal 0’s and 1’s<->
StringWord Wrap Problem [VERY IMP].<->
StringEDIT Distance [Very Imp]<->
StringFind next greater number with same set of digits. [Very Very IMP]<->
StringBalanced Parenthesis problem.[Imp]<->
StringWord break Problem[ Very Imp]<->
StringRabin Karp Algo<->
StringKMP Algo<->
StringConvert a Sentence into its equivalent mobile numeric keypad sequence.<->
StringMinimum number of bracket reversals needed to make an expression balanced.<->
StringCount All Palindromic Subsequence in a given String.<->
StringCount of number of given string in 2D character array<->
StringSearch a Word in a 2D Grid of characters.<->
StringBoyer Moore Algorithm for Pattern Searching.<->
StringConverting Roman Numerals to Decimal<->
StringLongest Common Prefix<->
StringNumber of flips to make binary string alternate<->
StringFind the first repeated word in string.<->
StringMinimum number of swaps for bracket balancing.<->
StringFind the longest common subsequence between two strings.<->
StringProgram to generate all possible valid IP addresses from given string.<->
StringWrite a program tofind the smallest window that contains all characters of string itself.<->
StringRearrange characters in a string such that no two adjacent are same<->
StringMinimum characters to be added at front to make string palindrome<->
StringGiven a sequence of words, print all anagrams together<->
StringFind the smallest window in a string containing all characters of another string<->
StringRecursively remove all adjacent duplicates<->
StringString matching where one string contains wildcard characters<->
StringFunction to find Number of customers who could not get a computer<->
StringTransform One String to Another using Minimum Number of Given Operation<->
StringCheck if two given strings are isomorphic to each other<->
StringRecursively print all sentences that can be formed from list of word lists<->
Searching & SortingFind first and last positions of an element in a sorted array<->
Searching & SortingFind a Fixed Point (Value equal to index) in a given arrayhttps://leetcode.com/problems/find-pivot-index/
Searching & SortingSearch in a rotated sorted arrayhttps://leetcode.com/problems/search-in-rotated-sorted-array/
Searching & Sortingsquare root of an integer<->
Searching & SortingMaximum and minimum of an array using minimum number of comparisons<->
Searching & SortingOptimum location of point to minimize total distancehttps://leetcode.com/problems/best-meeting-point/
Searching & SortingFind the repeating and the missing<->
Searching & Sortingfind majority element<->
Searching & SortingSearching in an array where adjacent differ by at most k<->
Searching & Sortingfind a pair with a given difference<->
Searching & Sortingfind four elements that sum to a given value<->
Searching & Sortingmaximum sum such that no 2 elements are adjacent<->
Searching & SortingCount triplet with sum smaller than a given value<->
Searching & Sortingmerge 2 sorted arrays<->
Searching & Sortingprint all subarrays with 0 sum<->
Searching & SortingProduct array Puzzle<->
Searching & SortingSort array according to count of set bits<->
Searching & Sortingminimum no. of swaps required to sort the array<->
Searching & SortingBishu and Soldiers<->
Searching & SortingRasta and Kheshtak<->
Searching & SortingKth smallest number againUsing Min Heap
Searching & SortingFind pivot element in a sorted array<->
Searching & SortingK-th Element of Two Sorted Arrays<->
Searching & SortingAggressive cows<->
Searching & SortingBook Allocation Problemhttps://leetcode.com/problems/capacity-to-ship-packages-within-d-days/
Searching & SortingEKOSPOJ:<->
Searching & SortingJob Scheduling Algo<->
Searching & SortingMissing Number in AP<->
Searching & SortingSmallest number with atleastn trailing zeroes infactorial<->
Searching & SortingPainters Partition Problem:<->
Searching & SortingROTI-Prata SPOJ<->
Searching & SortingDoubleHelix SPOJ<->
Searching & SortingSubset Sums<->
Searching & SortingFindthe inversion count<->
Searching & SortingImplement Merge-sort in-place<->
Searching & SortingPartitioning and Sorting Arrays with Many Repeated Entries<->
LinkedListWrite a Program to reverse the Linked List. (Both Iterative and recursive)<->
LinkedListReverse a Linked List in group of Given Size. [Very Imp]https://leetcode.com/problems/reverse-nodes-in-k-group/
LinkedListWrite a program to Detect loop in a linked list.<->
LinkedListWrite a program to Delete loop in a linked list.<->
LinkedListFind the starting point of the loop.<->
LinkedListRemove Duplicates in a sorted Linked List.
LinkedListRemove Duplicates from Sorted List II
LinkedListRemove Duplicates in a Un-sorted Linked List.
LinkedListWrite a Program to Move the last element to Front in a Linked List.<->
LinkedListAdd “1” to a number represented as a Linked List.<->
LinkedListAdd two numbers represented by linked lists.<->
LinkedListIntersection of two Sorted Linked List.<->
LinkedListIntersection Point of two Linked Lists.<->
LinkedListMerge Sort For Linked lists.[Very Important]<->
LinkedListQuicksort for Linked Lists.[Very Important]<->
LinkedListFind the middle Element of a linked list.<->
LinkedListCheck if a linked list is a circular linked list.<->
LinkedListSplit a Circular linked list into two halves.<->
LinkedListWrite a Program to check whether the Singly Linked list is a palindrome or not.<->
LinkedListDeletion from a Circular Linked List.<->
LinkedListReverse a Doubly Linked list.<->
LinkedListFind pairs with a given sum in a DLL.<->
LinkedListCount triplets in a sorted DLL whose sum is equal to given value “X”.<->
LinkedListSort a “k”sorted Doubly Linked list.[Very IMP]<->
LinkedListRotate DoublyLinked list by N nodes.<->
LinkedListRotate a Doubly Linked list in group of Given Size.[Very IMP]<->
LinkedListCan we reverse a linked list in less than O(n) ?<->
LinkedListWhy Quicksort is preferred for. Arrays and Merge Sort for LinkedLists ?<->
LinkedListFlatten a Linked List<->
LinkedListSort a LL of 0’s, 1’s and 2’s<->
LinkedListClone a linked list with next and random pointer<->
LinkedListMerge K sorted Linked list<->
LinkedListMultiply 2 no. represented by LL<->
LinkedListDelete nodes which have a greater value on right side<->
LinkedListSegregate even and odd nodes in a Linked List<->
LinkedListProgram for n’th node from the end of a Linked List<->
LinkedListFind the first non-repeating character from a stream of characters<->
Binary Treeslevel order traversal<->
Binary TreesReverse Level Order traversal<->
Binary TreesHeight of a tree<->
Binary TreesDiameter of a tree<->
Binary TreesMirror of a tree<->
Binary TreesInorder Traversal of a tree both using recursion and Iteration<->
Binary TreesPreorder Traversal of a tree both using recursion and Iteration<->
Binary TreesPostorder Traversal of a tree both using recursion and Iteration<->
Binary TreesLeft View of a tree<->
Binary TreesRight View of Treehttps://leetcode.com/problems/binary-tree-right-side-view/
Binary TreesTop View of a treehttps://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree/
Binary TreesBottom View of a tree<->
Binary TreesZig-Zag traversal of a binary treehttps://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/
Binary TreesCheck if a tree is balanced or not<->
Binary TreesDiagnol Traversal of a Binary treehttps://www.youtube.com/watch?v=e9ZGxH1y_PE
Binary TreesBoundary traversal of a Binary treehttps://www.youtube.com/watch?v=0ca1nvR0be4
Binary TreesConstruct Binary Tree from String with Bracket Representation<->
Binary TreesConvert Binary tree into Doubly Linked List<->
Binary TreesConvert Binary tree into Sum tree<->
Binary TreesConstruct Binary tree from Inorder and preorder traversal<->
Binary TreesFind minimum swaps required to convert a Binary tree into BST<->
Binary TreesCheck if Binary tree is Sum tree or not<->
Binary TreesCheck if all leaf nodes are at same level or not<->
Binary TreesCheck if a Binary Tree contains duplicate subtrees of size 2 or more [ IMP ]<->
Binary TreesCheck if 2 trees are mirror or not<->
Binary TreesSum of Nodes on the Longest path from root to leaf node<->
Binary TreesCheck if given graph is tree or not. [ IMP ]<->
Binary TreesFind Largest subtree sum in a tree<->
Binary TreesMaximum Sum of nodes in Binary tree such that no two are adjacent<->
Binary TreesPrint all “K” Sum paths in a Binary tree<->
Binary TreesFind LCA in a Binary tree<->
Binary TreesFind distance between 2 nodes in a Binary tree<->
Binary TreesKth Ancestor of node in a Binary tree<->
Binary TreesFind all Duplicate subtrees in a Binary tree [ IMP ]<->
Binary TreesTree Isomorphism Problem<->
Binary TreesCopy List with Random Pointer
Binary Search TreesFina a value in a BST<->
Binary Search TreesDeletion of a node in a BST<->
Binary Search TreesFind min and max value in a BST<->
Binary Search TreesFind inorder successor and inorder predecessor in a BST<->
Binary Search TreesCheck if a tree is a BST or not<->
Binary Search TreesPopulate Inorder successor of all nodes<->
Binary Search TreesFind LCA of 2 nodes in a BST<->
Binary Search TreesConstruct BST from preorder traversal<->
Binary Search TreesConvert Binary tree into BST<->
Binary Search TreesConvert a normal BST into a Balanced BST<->
Binary Search TreesMerge two BST [ V.V.V>IMP ]<->
Binary Search TreesFind Kth largest element in a BST<->
Binary Search TreesFind Kth smallest element in a BST<->
Binary Search TreesCount pairs from 2 BST whose sum is equal to given value “X”<->
Binary Search TreesFind the median of BST in O(n) time and O(1) space<->
Binary Search TreesCount BST ndoes that lie in a given range<->
Binary Search TreesReplace every element with the least greater element on its right<->
Binary Search TreesGiven “n” appointments, find the conflicting appointments<->
Binary Search TreesCheck preorder is valid or not<->
Binary Search TreesCheck whether BST contains Dead end<->
Binary Search TreesLargest BST in a Binary Tree [ V.V.V.V.V IMP ]<->
Binary Search TreesFlatten BST to sorted list<->
Binary Search TreesCheck Completeness of a Binary Tree
Binary Search TreesNon-overlapping Intervals
Binary Search TreesLargest BST in Binary Treehttps://leetcode.com/problems/maximum-sum-bst-in-binary-tree/
GreedyActivity Selection Problem<->
GreedyJob SequencingProblem<->
GreedyHuffman Coding<->
GreedyWater Connection Problem<->
GreedyFractional Knapsack Problem<->
GreedyGreedy Algorithm to find Minimum number of Coins<->
GreedyMaximum trains for which stoppage can be provided<->
GreedyMinimum Platforms Problem<->
GreedyBuy Maximum Stocks if i stocks can be bought on i-th day<->
GreedyFind the minimum and maximum amount to buy all N candies<->
GreedyMinimize Cash Flow among a given set of friends who have borrowed money from each otherOptimal Account Balancing
GreedyMinimum Cost to cut a board into squares<->
GreedyNumber of Islands<->
GreedyFind maximum meetings in one roomhttps://www.lintcode.com/problem/919
GreedyMaximum product subset of an array<->
GreedyMaximize array sum after K negations<->
GreedyMaximize the sum of arr[i]*i<->
GreedyMaximum sum of absolute difference of an array<->
GreedyMaximize sum of consecutive differences in a circular array<->
GreedyMinimum sum of absolute difference of pairs of two arrays<->
GreedyProgram for Shortest Job First (or SJF) CPU Scheduling<->
GreedyProgram for Least Recently Used (LRU) Page Replacement algorithm<->
GreedySmallest subset with sum greater than all other elements<->
GreedyChocolate Distribution Problem<->
GreedyDEFKIN -Defense of a Kingdom<->
GreedyDIEHARD -DIE HARD<->
GreedyGERGOVIA -Wine trading in Gergovia<->
GreedyPicking Up Chicks<->
GreedyCHOCOLA –Chocolate<->
GreedyARRANGE -Arranging Amplifiers<->
GreedyK Centers Problem<->
GreedyMinimum Cost of ropes<->
GreedyFind smallest number with given number of digits and sum of digits<->
GreedyRearrange characters in a string such that no two adjacent are same<->
GreedyFind maximum sum possible equal sum of three stacks<->
GreedyMaximum Sub-String after at most K changeshttps://leetcode.com/problems/maximize-the-confusion-of-an-exam/
BackTrackingRat in a maze Problem<->
BackTrackingPrinting all solutions in N-Queen Problem<->
BackTrackingWord Break Problem using Backtracking<->
BackTrackingRemove Invalid Parentheses<->
BackTrackingSudoku Solver<->
BackTrackingm Coloring Problem<->
BackTrackingPrint all palindromic partitions of a string<->
BackTrackingSubset Sum Problem<->
BackTrackingThe Knight’s tour problem<->
BackTrackingTug of War<->
BackTrackingFind shortest safe route in a path with landmines<->
BackTrackingCombinational Sum<->
BackTrackingFind Maximum number possible by doing at-most K swaps<->
BackTrackingPrint all permutations of a string<->
BackTrackingFind if there is a path of more than k length from a source<->
BackTrackingLongest Possible Route in a Matrix with Hurdles<->
BackTrackingPrint all possible paths from top left to bottom right of a mXn matrix<->
BackTrackingPartition of a set intoK subsets with equal sum<->
BackTrackingFind the K-th Permutation Sequence of first N natural numbers<->
Stacks & QueuesImplement Stack from Scratch<->
Stacks & QueuesImplement Queue from Scratch<->
Stacks & QueuesImplement 2 stack in an array<->
Stacks & Queuesfind the middle element of a stack<->
Stacks & QueuesImplement “N” stacks in an Array<->
Stacks & QueuesCheck the expression has valid or Balanced parenthesis or not.<->
Stacks & QueuesReverse a String using Stack<->
Stacks & QueuesDesign a Stack that supports getMin() in O(1) time and O(1) extra space.<->
Stacks & QueuesFind the next Greater element<->
Stacks & QueuesThe celebrity Problemhttps://www.youtube.com/watch?v=CiiXBvrX-5A
Stacks & QueuesArithmetic Expression evaluationhttps://leetcode.com/problems/evaluate-reverse-polish-notation/
Stacks & QueuesEvaluation of Postfix expressionhttps://www.youtube.com/watch?v=422Q_yx2yA8
Stacks & QueuesImplement a method to insert an element at its bottom without using any other data structure.<->
Stacks & QueuesReverse a stack using recursion<->
Stacks & QueuesSort a Stack using recursion<->
Stacks & QueuesMerge Overlapping Intervals<->
Stacks & QueuesLargest rectangular Area in Histogram<->
Stacks & QueuesLength of the Longest Valid Substring<->
Stacks & QueuesExpression contains redundant bracket or not<->
Stacks & QueuesImplement Stack using Queue<->
Stacks & QueuesImplement Stack using Deque<->
Stacks & QueuesStack Permutations (Check if an array is stack permutation of other)<->
Stacks & QueuesImplement Queue using Stack<->
Stacks & QueuesImplement “n” queue in an array<->
Stacks & QueuesImplement a Circular queue<->
Stacks & QueuesLRU Cache Implementationa<->
Stacks & QueuesReverse a Queue using recursion<->
Stacks & QueuesReverse the first “K” elements of a queue<->
Stacks & QueuesInterleave the first half of the queue with second half<->
Stacks & QueuesFind the first circular tour that visits all Petrol Pumps<->
Stacks & QueuesMinimum time required to rot all oranges<->
Stacks & QueuesDistance of nearest cell having 1 in a binary matrix<->
Stacks & QueuesFirst negative integer in every window of size “k”<->
Stacks & QueuesCheck if all levels of two trees are anagrams or not.<->
Stacks & QueuesSum of minimum and maximum elements of all subarrays of size “k”.<->
Stacks & QueuesMinimum sum of squares of character counts in a given string after removing “k” characters.<->
Stacks & QueuesQueue based approach or first non-repeating character in a stream.<->
Stacks & QueuesNext Smaller Element<->
HeapImplement a Maxheap/MinHeap using arrays and recursion.<->
HeapSort an Array using heap. (HeapSort)<->
HeapMaximum of all subarrays of size k.<->
Heap“k” largest element in an array<->
HeapKth smallest and largest element in an unsorted array<->
HeapMerge “K” sorted arrays. [ IMP ]<->
HeapMerge 2 Binary Max Heaps<->
HeapKth largest sum continuous subarrays<->
HeapLeetcode- reorganize strings<->
HeapMerge “K” Sorted Linked Lists [V.IMP]<->
HeapSmallest range in “K” Lists<->
HeapMedian in a stream of Integers<->
HeapCheck if a Binary Tree is Heap<->
HeapConnect “n” ropes with minimum cost<->
HeapConvert BST to Min Heap<->
HeapConvert min heap to max heap<->
HeapRearrange characters in a string such that no two adjacent are same.<->
HeapMinimum sum of two numbers formed from digits of an array<->
GraphCreate a Graph, print it<->
GraphImplement BFS algorithm<->
GraphImplement DFS Algo<->
GraphDetect Cycle in Directed Graph using BFS/DFS Algo<->
GraphDetect Cycle in UnDirected Graph using BFS/DFS Algo<->
GraphSearch in a Maze<->
GraphMinimum Step by Knight<->
Graphflood fill algo<->
GraphClone a graph<->
GraphMaking wired Connections<->
Graphword Ladder<->
GraphDijkstra algo<->
GraphImplement Topological Sort<->
GraphMinimum time taken by each job to be completed given by a Directed Acyclic Graph<->
GraphFind whether it is possible to finish all tasks or not from given dependencies<->
GraphFind the no. of Isalnds<->
GraphGiven a sorted Dictionary of an Alien Language, find order of characters<->
GraphImplement Kruksal’sAlgorithm<->
GraphImplement Prim’s Algorithm<->
GraphTotal no. of Spanning tree in a graph<->
GraphImplement Bellman Ford Algorithm<->
GraphImplement Floyd warshallAlgorithm<->
GraphTravelling Salesman Problem<->
GraphGraph ColouringProblem<->
GraphSnake and Ladders Problem<->
GraphFind bridge in a graph<->
GraphCount Strongly connected Components(Kosaraju Algo)<->
GraphCheck whether a graph is Bipartite or Not<->
GraphDetect Negative cycle in a graph<->
GraphLongest path in a Directed Acyclic Graph<->
GraphJourney to the Moon<->
GraphCheapest Flights Within K Stops<->
GraphOliver and the Game<->
GraphWater Jug problem using BFS<->
GraphWater Jug problem using BFS<->
GraphFind if there is a path of more thank length from a source<->
GraphM-ColouringProblem<->
GraphMinimum edges to reverse o make path from source to destination<->
GraphPaths to travel each nodes using each edge(Seven Bridges)<->
GraphVertex Cover Problem<->
GraphChinese Postman or Route Inspection<->
GraphNumber of Triangles in a Directed and Undirected Graph<->
GraphMinimise the cashflow among a given set of friends who have borrowed money from each other<->
GraphTwo Clique Problem<->
TrieConstruct a trie from scratch<->
TrieFind shortest unique prefix for every word in a given list<->
TrieWord Break Problem(Trie solution)
TrieGiven a sequence of words, print all anagrams together<->
TrieImplement a Phone Directory<->
TriePrint unique rows in a given boolean matrix<->
Dynamic ProgrammingCoin ChangeProblem<->
Dynamic ProgrammingKnapsack Problem<->
Dynamic ProgrammingBinomial CoefficientProblem<->
Dynamic ProgrammingPermutation CoefficientProblem<->
Dynamic ProgrammingProgram for nth Catalan Number<->
Dynamic ProgrammingMatrix Chain Multiplication<->
Dynamic ProgrammingEdit Distance<->
Dynamic ProgrammingSubset Sum Problem<->
Dynamic ProgrammingFriends Pairing Problem<->
Dynamic ProgrammingGold Mine Problem<->
Dynamic ProgrammingAssembly Line SchedulingProblem<->
Dynamic ProgrammingPainting the Fenceproblem<->
Dynamic ProgrammingMaximize The Cut Segments<->
Dynamic ProgrammingLongest Common Subsequence<->
Dynamic ProgrammingLongest Repeated Subsequence<->
Dynamic ProgrammingLongest Increasing Subsequence<->
Dynamic ProgrammingSpace Optimized Solution of LCS<->
Dynamic ProgrammingLCS (Longest Common Subsequence) of three strings<->
Dynamic ProgrammingMaximum Sum Increasing Subsequence<->
Dynamic ProgrammingCount all subsequences having product less than K<->
Dynamic ProgrammingLongest subsequence such that difference between adjacent is one<->
Dynamic ProgrammingMaximum subsequence sum such that no three are consecutive<->
Dynamic ProgrammingEgg Dropping Problem<->
Dynamic ProgrammingMaximum Length Chain of Pairs<->
Dynamic ProgrammingMaximum size square sub-matrix with all 1s<->
Dynamic ProgrammingMaximum sum of pairs with specific difference<->
Dynamic ProgrammingMin Cost PathProblem<->
Dynamic ProgrammingMaximum difference of zeros and ones in binary string<->
Dynamic ProgrammingMinimum number of jumps to reach end<->
Dynamic ProgrammingMinimum cost to fill given weight in a bag<->
Dynamic ProgrammingMinimum removals from array to make max –min <= K<->
Dynamic ProgrammingLongest Common Substring<->
Dynamic ProgrammingCount number of ways to reacha given score in a game<->
Dynamic ProgrammingCount Balanced Binary Trees of Height h<->
Dynamic ProgrammingLargestSum Contiguous Subarray [V>V>V>V IMP ]<->
Dynamic ProgrammingSmallest sum contiguous subarray<->
Dynamic ProgrammingUnbounded Knapsack (Repetition of items allowed)<->
Dynamic ProgrammingWord Break Problem<->
Dynamic ProgrammingLargest Independent Set Problem<->
Dynamic ProgrammingPartition problem<->
Dynamic ProgrammingLongest Palindromic Subsequence<->
Dynamic ProgrammingCount All Palindromic Subsequence in a given String<->
Dynamic ProgrammingLongest Palindromic Substring<->
Dynamic ProgrammingLongest alternating subsequence<->
Dynamic ProgrammingWeighted Job Scheduling<->
Dynamic ProgrammingCoin game winner where every player has three choices<->
Dynamic ProgrammingCount Derangements (Permutation such that no element appears in its original position) [ IMPORTANT ]<->
Dynamic ProgrammingMaximum profit by buying and selling a share at most twice [ IMP ]<->
Dynamic ProgrammingOptimal Strategy for a Game<->
Dynamic ProgrammingOptimal Binary Search Tree<->
Dynamic ProgrammingPalindrome PartitioningProblem<->
Dynamic ProgrammingWord Wrap Problem<->
Dynamic ProgrammingMobile Numeric Keypad Problem [ IMP ]<->
Dynamic ProgrammingBoolean Parenthesization Problem<->
Dynamic ProgrammingLargest rectangular sub-matrix whose sum is 0<->
Dynamic ProgrammingLargest area rectangular sub-matrix with equal number of 1’s and 0’s [ IMP ]<->
Dynamic ProgrammingMaximum sum rectangle in a 2D matrix<->
Dynamic ProgrammingMaximum profit by buying and selling a share at most k times<->
Dynamic ProgrammingFind if a string is interleaved of two other strings<->
Dynamic ProgrammingMaximum Length of Pair Chain<->
Dynamic ProgrammingPartition Equal Subset Sumhttps://leetcode.com/submissions/detail/561942165/
Dynamic ProgrammingTarget Sum
Bit ManipulationCount set bits in an integer<->
Bit ManipulationFind the two non-repeating elements in an array of repeating elements<->
Bit ManipulationCount number of bits to be flipped to convert A to B<->
Bit ManipulationCount total set bits in all numbers from 1 to n<->
Bit ManipulationProgram to find whether a no is power of two<->
Bit ManipulationFind position of the only set bit<->
Bit ManipulationCopy set bits in a range<->
Bit ManipulationDivide two integers without using multiplication, division and mod operator<->
Bit ManipulationCalculate square of a number without using *, / and pow()<->
Bit ManipulationPower Set<->
Moore voting algorithmMajority Elementhttps://www.youtube.com/watch?v=n5QY3x_GNDg
Moore voting algorithmMajority Element IIhttps://www.youtube.com/watch?v=yDbkQd9t2ig

30 Days Interview Preparation Plan 🎯

Originally the below sheet was prepared by Raj Vikramaditya A.K.A Striver . I have documented this sheet here in markdown.

Day1: (Arrays)

  1. Sort an array of 0’s 1’s 2’s without using extra space or sorting algo

  2. Repeat and Missing Number

  3. Merge two sorted Arrays without extra space

  4. Kadane’s Algorithm

  5. Merge Overlapping Subintervals

  6. Find the duplicate in an array of N+1 integers.

Day2: (Arrays)

  1. Set Matrix Zeros

  2. Pascal Triangle

  3. Next Permutation

  4. Inversion of Array (Using Merge Sort)

  5. Stock Buy and Sell

  6. Ro tate Matrix

Day3: (Arrays/maths)

  1. Search in a 2D matrix

  2. Pow(X,n)

  3. Majority Element (>N/2 times)

  4. Majority Element (>N/3 times)

  5. Grid Unique Paths

  6. Reverse Pairs (Leetcode)

  7. Go through Puzzles from GFG** (Search on own)

Day4: (Hashing)

  1. 2 Sum problem

  2. 4 Sum problem

  3. Longest Consecutive Sequence

  4. Largest Subarray with 0 sum

  5. Count number of subarrays with given XOR (this clearsa lot of problems)

  6. Longest substring without repeat

Day5: (LinkedList)

  1. Reverse a LinkedList

  2. Find middle of LinkedList

  3. Merge two sorted Linked List

  4. Remove N-th node from back of LinkedList

  5. Delete a given Node when a node is given. (0(1) solution)

  6. Add two numbers as LinkedList

Day6:

  1. Find intersection point of Y LinkedList

  2. Detect a cycle in Linked List

  3. Reverse a LinkedList in groups of size k

  4. Check if a LinkedList is palindrome or not.

  5. Find the starting point of the Loop of LinkedList

  6. Flattening of a LinkedList**

  7. Rotate a LinkedList

Day7: (2-pointer)

  1. Clone a Linked List with random and next pointer

  2. 3 sum

  3. Trapping rainwater

  4. Remove Duplicate from Sorted array

  5. Max consecutive ones

Day8: (Greedy)

  1. N meeting in one room

  2. Minimum number of platforms required for a railway

  3. Job sequencing Problem

  4. Fractional Knapsack Problem

  5. Greedy algorithm to find minimum number of coins

  6. Activity Selection (it i

  7. s same as N meeting in one room)

Day9 (Recursion):

  1. Subset Sums

  2. Subset-II

  3. Combination sum-

  4. Combination sum

  5. Palindrome Partitioning

  6. K-th permutation Sequence

Day10: (Recursion and Backtracking)

  1. Print all Permutations of a string/array

  2. N queens Problem

  3. SudokuSolver

  4. M coloring Problem

  5. Rat in a Maze

6.Word Break -> print all ways

Day11 : (Binary Search)

  1. N-th root of an integer (use binary search) (square root, cube root, ..)

  2. Matrix Median

  3. Find the element that appears once in sorted array, and rest element appears twice (Binary search)

  4. Search element in a sorted and rotated array/ find pivot where it is rotated**

  5. Median of 2 sorted arrays

  6. K-th element of two sorted arrays

  7. Allocate Minimum Number of Pages

  8. Aggressive Cows

Day12: (Bits) (Optional, very rare topic in interviews, but if you have time left, someone might ask)

  1. Check if a number if a power of 2 or not in O(1)
  2. Count total set bits
  3. Divide Integers without / operator
  4. Power Set (this is very important)
  5. Find MSB in o(1)
  6. Find square of a number without using multiplication or division operators.

Day13: (Stack and Queue)

  1. Implement Stack Using Arrays

  2. Implement Queue Using Arrays

  3. Implement Stack using Queue (using single queue)

  4. Implement Queue using Stack (0(1) amortised method)

  5. Check for balanced parentheses

  6. Next Greater Element

  7. Sort a Stack

Day14:

  1. Next Smaller Element Similar to previous question next greater element, just do pop the greater elements out ..

  2. LRU cache (vvvv. imp)

  3. LFU Cache (Hard, can be ignored)

4.Largest rectangle in histogram (Do the one pass solution)

Two pass

One pass

  1. Sliding Window maximum video
  2. Implement Min Stack
  3. Rotten Orange (Using BFS)
  4. Stock Span Problem
  5. Find maximum of minimums of every window size 10.The Celebrity Problem

Day15: (String)

  1. Reverse Words in a String
  2. Longest Palindrome in a string
  3. Roman Number to Integer and vice versa
  4. Implement ATOI/STRSTR
  5. Longest Common Prefix
  6. Rabin Karp

Day16: (String)

  1. Prefix Function/Z-Function
  2. KMP algo / LPS(pi) array
  3. Minimum characters needed to be inserted in the beginning to make it palindromic.
  4. Check for Anagrams
  5. Count and Say
  6. Compare version numbers

Day17: (Binary Tree)

  1. Inorder Traversal (with recursion and without recursion)
  2. Preorder Traversal (with recursion and without recursion)
  3. Postorder Traversal (with recursion and without recursion)
  4. LeftView Of Binary Tree
  5. Bottom View of Binary Tree
  6. Top View of Binary Tree**

Day18: (Binary Tree)

  1. Level order Traversal / Level order traversal in spiral form
  2. Height of a Binary Tree
  3. Diameter of Binary Tree
  4. Check if Binary tree is height balanced or not
  5. LCA in Binary Tree
  6. Check if two trees are identical or not**

Day 19: (Binary Tree)

  1. Maximum path sum
  2. Construct Binary Tree from inorder and preorder
  3. Construct Binary Tree from Inorder and Postorder
  4. Symmetric Binary Tree
  5. Flatten Binary Tree to LinkedList
  6. Check if Binary Tree is mirror of itself or not

Day 20: (Binary Search Tree)

  1. Populate Next Right pointers of Tree
  2. Search given Key in BST
  3. Construct BST from given keys.
  4. Check is a BT is BST or not
  5. Find LCA of two nodes in BST
  6. Find the inorder predecessor/successor of a given Key in BST.**

Day21: (BinarySearchTree)

  1. Floor and Ceil in a BST
  2. Find K-th smallest and K-th largest element in BST (2 different Questions)
  3. Find a pair with a given sum in BST
  4. BST iterator
  5. Size of the largest BST in a Binary Tree
  6. Serialize and deserialize Binary Tree

Day22: (Mixed Questions)

  1. Binary Tree to Double Linked List
  2. Find median in a stream of running integers.
  3. K-th largest element in a stream.
  4. Distinct numbers in Window.
  5. K-th largest element in an unsorted array.
  6. Flood-fill Algorithm

Day23: (Graph) Theory

  1. Clone a graph (Not that easy as it looks)
  2. DFS
  3. BFS
  4. Detect A cycle in Undirected Graph/Directed Graph
  5. Topo Sort
  6. Number of islands (Do in Grid and Graph both)
  7. Bipartite Check

Day24: (Graph) Theory

  1. SCC(using KosaRaju’s algo)
  2. Djisktra’s Algorithm
  3. Bellman Ford Algo
  4. Floyd Warshall Algorithm
  5. MST using Prim’s Algo
  6. MST using Kruskal’s Algo

Day25: (Dynamic Programming)

  1. Max Product Subarray
  2. Longest Increasing Subsequence
  3. Longest Common Subsequence
  4. 0-1 Knapsack
  5. Edit Distance
  6. Maximum sum increasing subsequence
  7. Matrix Chain Multiplication

Day26: (DP)

  1. Maximum sum path in matrix, (count paths, and similar type do, also backtrack to find the maximum path)
  2. Coin change
  3. Subset Sum
  4. Rod Cutting
  5. Egg Dropping
  6. Word Break
  7. Palindrome Partitioning (MCM Variation)
  8. Maximum profit in Job scheduling For core revision</>

Day27:

  1. Revise OS notes that you would have made during your sem
  2. If not made notes, spend 2 or 3 days and make notes from Knowledge Gate.

Day28:

  1. Revise DBMS notes that you would have made during your semesters.
  2. If not made notes, spend 2 or 3 days and make notes from Knowledge Gate.

Day29:

  1. Revise CN notes, that you would have made during your sem.
  2. If not made notes, spend 2 or 3 days and make notes from Knowledge Gate.

Day30:

  1. Make a note of how will your represent your projects, and prepare all questions related to tech which you have used in your projects. Prepare a note which you can say for 3-10 minutes when he asks you that say something about the project.

System Design – Concepts📚

  1. https://github.com/SamirPaul1/system-design-primer

  2. https://www.freecodecamp.org/news/systems-design-for-interviews/

  3. https://github.com/shashank88/system_design