Wanted to share free data structure problems for students who can't afford leetcode

Array

  1. Find pair with given sum in the array  
  2. Check if subarray with 0 sum is exists or not  
  3. Print all sub-arrays with 0 sum  
  4. Sort binary array in linear time  
  5. Find a duplicate element in a limited range array  
  6. Find maximum length sub-array having given sum  
  7. Find maximum length sub-array having equal number of 0’s and 1’s  
  8. Sort an array containing 0’s, 1’s and 2’s (Dutch national flag problem)  
  9. In place merge two sorted arrays  
  10. Merge two arrays by satisfying given constraints  
  11. Find index of 0 to replace to get maximum length sequence of continuous ones  
  12. Find maximum product of two integers in an array  
  13. Shuffle a given array of elements (Fisher–Yates shuffle)  
  14. Rearrange the array with alternate high and low elements  
  15. Find equilibrium index of an array  
  16. Find largest sub-array formed by consecutive integers  
  17. Find majority element in an array (Boyer–Moore majority vote algorithm)  
  18. Move all zeros present in the array to the end  
  19. Replace each element of array with product of every other element without using / operator  
  20. Find Longest Bitonic Subarray in an array  
  21. Find maximum difference between two elements in the array by satisfying given constraints  
  22. Maximum subarray problem (Kadane’s algorithm)  
  23. Print continuous subarray with maximum sum  
  24. Maximum Sum Circular Subarray  
  25. Find all distinct combinations of given length  
  26. Find all distinct combinations of given length with repetition allowed  
  27. Find maximum sequence of continuous 1’s formed by replacing at-most k zeroes by ones  
  28. Find minimum sum subarray of given size k  
  29. Find subarray having given sum in given array of integers  
  30. Find the length of smallest subarray whose sum of elements is greater than the given number  
  31. Find largest number possible from set of given numbers  
  32. Find the smallest window in array sorting which will make the entire array sorted  
  33. Find maximum sum path involving elements of given arrays  
  34. Maximum profit earned by buying and selling shares any number of times  
  35. Trapping Rain Water within given set of bars  
  36. Longest Increasing Subsequence  
  37. Longest Decreasing Subsequence Problem  
  38. Find maximum product subarray in a given array  
  39. Find maximum sum of subsequence with no adjacent elements  
  40. Find minimum platforms needed in the station so to avoid any delay in arrival of any train  
  41. Decode the array constructed from another array  
  42. Sort an array using one swap  
  43. Find Triplet with given sum in an array  
  44. Length of longest continuous sequence with same sum in given binary arrays  
  45. Rearrange array such that A[A[i]] is set to i for every element A[i]  
  46. Reverse every consecutive m elements of the given subarray  
  47. Maximum Product Subset Problem  
  48. Find pairs with given difference k in the array  
  49. Find pairs with given difference k in the array | Constant space solution  
  50. 4 sum problem | Quadruplets with given sum  
  51. Print all quadruplets with given sum | 4-sum problem extended  
  52. Find odd occurring element in an array in single traversal  
  53. Find two odd occurring elements in an array without using any extra space  
  54. Quickselect Algorithm  
  55. Print all Triplets that forms Arithmetic Progression  
  56. Print all triplets that forms Geometric Progression  
  57. Print all combination of numbers from 1 to n having sum n  
  58. Replace each element of the array by its corresponding rank in the array  
  59. Print all Triplets in an array with sum less than or equal to given number  
  60. Group elements of an array based on their first occurrence  
  61. Find minimum difference between index of two given elements present in the array  
  62. Find maximum absolute difference between sum of two non-overlapping sub-arrays  
  63. Find all Symmetric Pairs in an Array of Pairs  
  64. Partition an array into two sub-arrays with the same sum  
  65. Find count of distinct elements in every sub-array of size k  
  66. Find two numbers with maximum sum formed by array digits  
  67. Print all sub-arrays of an array having distinct elements  
  68. Find a Triplet having Maximum Product in an Array  
  69. Find ways to calculate a target from elements of specified array  
  70. Find Minimum Index of Repeating Element in an Array  
  71. Generate Random Input from an Array according to given Probabilities  
  72. Find pair in an array having minimum absolute sum  
  73. Find Index of Maximum Occurring Element with Equal Probability  
  74. Check if an Array is Formed by Consecutive Integers  
  75. Find two non-overlapping pairs having same sum in an array  
  76. Find Minimum Product among all Combinations of Triplets in an Array  
  77. Replace every element of an array with the least greater element on its right  
  78. Find all odd occurring elements in an array having limited range of elements  
  79. Add elements of two arrays into a new array  
  80. Count the distinct absolute values in the sorted array  
  81. Print all combinations of positive integers in increasing order that sum to a given number  
  82. Find all distinct combinations of given length - Part 2  
  83. Find subarrays with given sum in an array  
  84. Find the surpasser count for each element of an array  
  85. Find maximum length sequence of continuous ones (Using Sliding Window)  
  86. Find maximum length sequence of continuous ones  
  87. Calculate frequency of all elements present in an array of specified range  
  88. Rearrange the array such that it contains positive and negative numbers at alternate positions  
  89. Find a sorted triplet in the given array  
  90. Shuffle an array according to the given order of elements  
  91. Find index that divides an array into two non-empty subarrays of equal sum  
  92. Count number of strictly increasing sub-arrays in an array  
  93. Find minimum range with at-least one element from each of the given arrays  
  94. Find longest subsequence formed by consecutive integers  
  95. Find duplicates within given range k in an array  
  96. Longest Alternating Subarray Problem  
  97. Find all elements in an array that are greater than all elements present to their right  
  98. Find missing number in array without using extra space  
  99. Difference between Subarray, Subsequence and Subset  

Backtracking

  1. Print all possible solutions to N Queens problem  
  2. Print all Possible Knight’s Tours in a chessboard  
  3. Find Shortest Path in Maze  
  4. Find Longest Possible Route in a Matrix  
  5. Find path from source to destination in a matrix that satisfies given constraints  
  6. Find total number of unique paths in a maze from source to destination  
  7. Print All Hamiltonian Path present in a graph  
  8. Print all k-colorable configurations of the graph (Vertex coloring of graph)  
  9. Find all Permutations of a given string  
  10. All combinations of elements satisfying given constraints  
  11. Find all binary strings that can be formed from given wildcard pattern  
  12. K-Partition Problem | Printing all Partitions  
  13. Magnet Puzzle  
  14. Find ways to calculate a target from elements of specified array  
  15. Find minimum number possible by doing at-most K swaps  
  16. Determine if a pattern matches with a string or not  
  17. Generate list of possible words from a character matrix  
  18. Find the path between given vertices in a directed graph  
  19. Find all Possible Topological Orderings of a DAG  

Bit Manipulation

  1. Bit Hacks – Part 1 (Basic)  
  2. Bit Hacks – Part 2 (Playing with k’th bit)  
  3. Bit Hacks – Part 3 (Playing with rightmost set bit of a number)  
  4. Bit Hacks – Part 4 (Playing with letters of English alphabet)  
  5. Bit Hacks – Part 5 (Find absolute value of an integer without branching)  
  6. Bit Hacks – Part 6 (Random Problems)  
  7. Brian Kernighan’s Algorithm to count set bits in an integer  
  8. Compute parity of a number using lookup table  
  9. Count set bits using lookup table  
  10. Find the minimum or maximum of two integers without using branching  
  11. Multiply 16-bit integers using 8-bit multiplier  
  12. Round up to the next highest power of 2  
  13. Round up to the previous power of 2  
  14. Swap individual bits at given position in an integer  
  15. Check if given number is power of 4 or not  
  16. Reverse Bits of a given Integer  
  17. Find odd occurring element in an array in single traversal  
  18. Find two odd occurring elements in an array without using any extra space  
  19. Swap two bits at given position in an integer  
  20. Add binary representation of two integers  
  21. Swap Adjacent Bits of a Number  
  22. Print all distinct Subsets of a given Set  
  23. Perform Division of two numbers without using division operator (/)  
  24. Check if adjacent bits are set in binary representation of a given number  
  25. Conditionally negate a value without branching  
  26. Find two duplicate elements in a limited range array (using XOR)  
  27. Find missing number and duplicate elements in an array  
  28. Check if given number is power of 8 or not  
  29. Circular shift on binary representation of an integer by k positions  
  30. Solve given set of problems without using multiplication or division operators  
  31. Reverse Bits of an integer using lookup table  

Binary Tree

  1. Check if two given binary trees are identical or not | Iterative & Recursive  
  2. Calculate height of a binary tree | Iterative & Recursive  
  3. Delete given Binary Tree | Iterative & Recursive  
  4. Inorder Tree Traversal | Iterative & Recursive  
  5. Preorder Tree Traversal | Iterative & Recursive  
  6. Postorder Tree Traversal | Iterative & Recursive  
  7. Level Order Traversal of Binary Tree  
  8. Spiral Order Traversal of Binary Tree  
  9. Reverse Level Order Traversal of Binary Tree  
  10. Print all nodes of a given binary tree in specific order  
  11. Print left view of binary tree  
  12. Print Bottom View of Binary Tree  
  13. Print Top View of Binary Tree  
  14. Find next node in same level for given node in a binary tree  
  15. Check if given binary tree is complete binary tree or not  
  16. Determine if given two nodes are cousins of each other  
  17. Print cousins of given node in a binary tree  
  18. In-place convert given binary tree to its sum tree  
  19. Check if given binary tree is a sum tree or not  
  20. Combinations of words formed by replacing given numbers with corresponding alphabets  
  21. Determine if given binary tree is a subtree of another binary tree or not  
  22. Find diameter of a binary tree  
  23. Check if given binary Tree has symmetric structure or not  
  24. Convert binary tree to its mirror  
  25. Check if binary tree can be converted to another by doing any no. of swaps of left & right child  
  26. Find Lowest Common Ancestor (LCA) of two nodes in a binary tree  
  27. Print all paths from root to leaf nodes in a binary tree  
  28. Find ancestors of given node in a Binary Tree  
  29. Find the distance between given pairs of nodes in a binary tree  
  30. Find Vertical Sum in a given Binary Tree  
  31. Print nodes in vertical order of a given Binary Tree (Vertical Traversal)  
  32. Find the diagonal sum of given binary tree  
  33. Print Diagonal Traversal of Binary Tree  
  34. Print corner nodes of every level in binary tree  
  35. In-place convert given Binary Tree to Doubly Linked List  
  36. Sink nodes containing zero to the bottom of the binary tree  
  37. Convert given binary tree to full tree by removing half nodes  
  38. Truncate given binary tree to remove nodes which lie on a path having sum less than K  
  39. Find maximum sum root-to-leaf path in a binary tree  
  40. Check if given binary tree is height balanced or not  
  41. Convert normal binary tree to Left-child right-sibling binary tree  
  42. Determine if given Binary Tree is a BST or not  
  43. Convert a Binary Tree to BST by maintaining its original structure  
  44. Invert given Binary Tree | Recursive and Iterative solution  
  45. Print Right View of a Binary Tree  
  46. Print all paths from leaf to root node in given binary tree  
  47. Iteratively print leaf to root path for every leaf node in a binary tree  
  48. Find maximum width of given binary tree  
  49. Build Binary Tree from given Parent array  
  50. Find all nodes at given distance from leaf nodes in a binary tree  
  51. Count all subtrees having same value of nodes in a binary tree  
  52. Find Maximum Difference Between a Node and its Descendants in a Binary Tree  
  53. Construct a Binary Tree from Ancestor Matrix  
  54. Calculate height of a binary tree with leaf nodes forming a circular doubly linked list  
  55. Find maximum sum path between two leaves in a binary tree  
  56. Fix a binary tree that is only one swap away from becoming a BST  
  57. Construct a binary tree from inorder and preorder traversal  
  58. Construct a binary tree from inorder and postorder traversals  
  59. Construct a binary tree from inorder and level order sequence  
  60. Construct a full binary tree from preorder sequence with leaf node information  
  61. Construct a full binary tree from a preorder and postorder sequence  
  62. Set next pointer to inorder successor of all nodes in binary tree  
  63. Efficiently print all nodes between two given levels in a binary tree  
  64. Find preorder traversal of a binary tree from its inorder and postorder sequence  
  65. Find the difference between sum of all nodes present at odd and even levels in a binary tree  
  66. Find the size of the largest BST in a Binary Tree  
  67. Print nodes of a given binary tree in vertical order  
  68. Link nodes present in each level of a binary tree in the form of a linked list  
  69. Construct a Cartesian Tree from In-order Traversal  
  70. Implementation of Treap Data Structure (Insert, Search and Delete)  
  71. Depth first search (DFS) vs Breadth first search (BFS)  
  72. Clone a binary tree with random pointers  
  73. Threaded Binary Tree: Overview and Implementation  
  74. Invert alternate levels of a perfect binary tree  
  75. Convert a binary tree into a doubly linked list in spiral order  
  76. Check if a binary tree is a min-heap or not  

Binary Search Tree

  1. Insertion in BST  
  2. Search given key in BST  
  3. Deletion from BST  
  4. Construct balanced BST from given keys  
  5. Determine if given Binary Tree is a BST or not  
  6. Check if given keys represents same BSTs or not without building the BST  
  7. Find inorder predecessor for given key in a BST  
  8. Find Lowest Common Ancestor (LCA) of two nodes in a Binary Search Tree  
  9. Find K’th smallest and K’th largest element in BST  
  10. Floor and Ceil in a Binary Search Tree  
  11. Find optimal cost to construct binary search tree  
  12. Convert a Binary Tree to BST by maintaining its original structure  
  13. Remove nodes from BST that have keys outside the valid range  
  14. Find a pair with given sum in a BST  
  15. Find inorder successor for given key in a BST  
  16. Replace every element of an array with the least greater element on its right  
  17. Fix a binary tree that is only one swap away from becoming a BST  
  18. Update every key in BST to contain sum of all greater keys  
  19. Check if a given sequence represents preorder traversal of a BST  
  20. Build a Binary Search Tree from a Postorder Sequence  
  21. Build a Binary Search Tree from a Preorder Sequence  
  22. Find a triplet with given sum in a BST  
  23. Count subtrees in a BST whose nodes lies within a given range  
  24. Merge two BSTs into a doubly linked list in sorted order  
  25. Construct a height-balanced BST from an unbalanced BST  
  26. Find the size of the largest BST in a Binary Tree  
  27. Convert a Binary Search Tree into a Min Heap  

Divide & Conquer

  1. Binary Search  
  2. Find number of rotations in a circularly sorted array  
  3. Search an element in a circular sorted array  
  4. Find first or last occurrence of a given number in a sorted array  
  5. Count occurrences of a number in a sorted array with duplicates  
  6. Find smallest missing element from a sorted array  
  7. Find Floor and Ceil of a number in a sorted array  
  8. Search in a nearly sorted array in O(log(n)) time  
  9. Find number of 1’s in a sorted binary array  
  10. Find the peak element in an array  
  11. Maximum Sum Subarray using Divide & Conquer  
  12. Find Minimum and Maximum element in an array using minimum comparisons  
  13. Efficiently implement power function | Recursive and Iterative  
  14. Find Missing Term in a Sequence in log(n) time  
  15. Division of Two Numbers using Binary Search Algorithm  
  16. Find Floor and Ceil of a number in a sorted array (Recursive solution)  
  17. Find Minimum and Maximum element in an array by doing minimum comparisons  
  18. Find Frequency of each element in a sorted array containing duplicates  
  19. Ternary Search vs Binary search  
  20. Exponential search  
  21. Interpolation search  

Dynamic Programming

  1. Introduction to Dynamic Programming  
  2. Longest Common Subsequence | Introduction & LCS Length  
  3. Longest Common Subsequence | Space optimized version  
  4. Longest Common Subsequence of K-sequences  
  5. Longest Common Subsequence | Finding all LCS  
  6. Longest Common Substring problem  
  7. Longest Palindromic Subsequence using Dynamic Programming  
  8. Longest Repeated Subsequence problem  
  9. Implement Diff Utility  
  10. Shortest Common Supersequence | Introduction & SCS Length  
  11. Shortest Common Supersequence | Finding all SCS  
  12. Shortest Common Supersequence | Using LCS  
  13. Longest Increasing Subsequence using Dynamic Programming  
  14. Longest Bitonic Subsequence  
  15. Increasing Subsequence with Maximum Sum  
  16. The Levenshtein distance (Edit distance) problem  
  17. Find size of largest square sub-matrix of 1’s present in given binary matrix  
  18. Matrix Chain Multiplication  
  19. Find the minimum cost to reach last cell of the matrix from its first cell  
  20. Find longest sequence formed by adjacent numbers in the matrix  
  21. Count number of paths in a matrix with given cost to reach destination cell  
  22. 0-1 Knapsack problem  
  23. Maximize value of the expression  
  24. Partition problem  
  25. Subset sum problem  
  26. Minimum Sum Partition problem  
  27. Find all N-digit binary strings without any consecutive 1’s  
  28. Rod Cutting  
  29. Maximum Product Rod Cutting  
  30. Coin change-making problem (unlimited supply of coins)  
  31. Coin Change Problem – Find total number of ways to get the denomination of coins  
  32. Total possible solutions to linear equation of k variables  
  33. Longest alternating subsequence  
  34. Count number of times a pattern appears in given string as a subsequence  
  35. Collect maximum points in a matrix by satisfying given constraints  
  36. Count total possible combinations of N-digit numbers in a mobile keypad  
  37. Find optimal cost to construct binary search tree  
  38. Word Break Problem  
  39. Word Break Problem | Using Trie Data Structure  
  40. Determine Minimal Adjustment Cost of an Array  
  41. Check if a string is K-Palindrome or not  
  42. Find total ways to achieve given sum with n throws of dice having k faces  
  43. Wildcard Pattern Matching  
  44. Find number of ways to fill a N x 4 matrix with 1 x 4 tiles  
  45. Ways to reach the bottom-right corner of a matrix with exactly k turns allowed  
  46. Weighted Interval Scheduling Problem  
  47. Box Stacking Problem  
  48. Find total ways to reach the n'th stair with at-most m steps  
  49. Find total ways to reach the n'th stair from the bottom  
  50. Activity Selection Problem using Dynamic Programming  
  51. Find minimum number of deletions required to convert a string into palindrome  
  52. Calculate minimum cost to reach destination city from source city  
  53. Weighted Interval Scheduling - Dynamic Programming Solution  
  54. Find minimum jumps required to reach the destination    
  55. Find probability that a person is alive after taking N steps on the island  
  56. Calculate sum of all elements in a sub-matrix in constant time  
  57. Find maximum sum K x K sub-matrix in a given M x N matrix  
  58. Find maximum sum submatrix present in a given matrix  
  59. Find maximum sum of subsequence with no adjacent elements  
  60. Maximum subarray problem (Kadane’s algorithm)  
  61. Single-Source Shortest Paths – Bellman Ford Algorithm  
  62. All-Pairs Shortest Paths – Floyd Warshall Algorithm  
  63. Longest Decreasing Subsequence Problem  
  64. Pots of Gold Game using Dynamic Programming  
  65. Find minimum cuts needed for palindromic partition of a string  
  66. Maximum Length Snake Sequence  
  67. 3 Partition Problem  
  68. Calculate size of the largest plus of 1's in binary matrix  
  69. Check if given string is interleaving of two other given strings  
  70. Longest Increasing Subsequence using LCS  
  71. Determine negative-weight cycle in a graph  
  72. Longest Alternating Subarray Problem  

Graph

  1. Terminology and Representations of Graphs  
  2. Graph Implementation using STL  
  3. Graph Implementation in C++ without using STL  
  4. Graph Implementation in C  
  5. Graph Implementation in Java using Collections  
  6. Breadth First Search (BFS) | Iterative & Recursive Implementation  
  7. Depth First Search (DFS) | Iterative & Recursive Implementation  
  8. Arrival and Departure Time of Vertices in DFS  
  9. Types of edges involved in DFS and relation between them  
  10. Bipartite Graph  
  11. Determine if a given graph is Bipartite Graph using DFS  
  12. Minimum number of throws required to win Snake and Ladder game  
  13. Topological Sorting in a DAG  
  14. Kahn's Topological Sort Algorithm  
  15. Transitive Closure of a Graph  
  16. Check if an undirected graph contains cycle or not  
  17. Total paths in given digraph from given source to destination having exactly m edges  
  18. Determine if an undirected graph is a Tree (Acyclic Connected Graph)  
  19. 2-Edge Connectivity in the graph  
  20. 2-Vertex Connectivity in the graph  
  21. Check if given digraph is a DAG (Directed Acyclic Graph) or not  
  22. Disjoint-Set Data Structure (Union-Find Algorithm)  
  23. Chess Knight Problem – Find Shortest path from source to destination  
  24. Check if given Graph is Strongly Connected or not  
  25. Check if given Graph is Strongly Connected or not using one DFS Traversal  
  26. Union-Find Algorithm for Cycle Detection in undirected graph  
  27. Kruskal’s Algorithm for finding Minimum Spanning Tree  
  28. Single-Source Shortest Paths – Dijkstra’s Algorithm  
  29. Single-Source Shortest Paths – Bellman Ford Algorithm  
  30. All-Pairs Shortest Paths – Floyd Warshall Algorithm  
  31. Find Cost of Shortest Path in DAG using one pass of Bellman-Ford  
  32. Least Cost Path in Weighted Digraph using BFS  
  33. Find maximum cost path in graph from given source to destination  
  34. Determine negative-weight cycle in a graph  
  35. Least cost path in given digraph from given source to destination having exactly m edges  
  36. Find the path between given vertices in a directed graph  
  37. Find all Possible Topological Orderings of a DAG  
  38. Find the correct order of alphabets in a given dictionary of ancient origin  
  39. Find longest path in a Directed Acyclic Graph (DAG)  

Heap

  1. Introduction to Priority Queues using Binary Heaps  
  2. Min Heap and Max Heap Implementation in C++  
  3. Min Heap and Max Heap Implementation in Java  
  4. Heap Sort Algorithm  
  5. Check if given array represents min heap or not  
  6. Convert Max Heap to Min Heap in linear time  
  7. Find K’th largest element in an array  
  8. Sort a K-Sorted Array  
  9. Merge M sorted lists of variable length  
  10. Merge K sorted linked lists  
  11. Find K’th smallest element in an array  
  12. Find smallest range with at-least one element from each of the given lists  
  13. Merge M sorted lists each containing N elements    
  14. External merge sort  
  15. Huffman Coding  
  16. Find first k maximum occurring words in given set of strings  
  17. Find first k non-repeating characters in a string in single traversal  
  18. Implementation of Treap Data Structure (Insert, Search and Delete)  
  19. Convert a Binary Search Tree into a Min Heap  
  20. Check if a binary tree is a min-heap or not  

Linked List

  1. Introduction to Linked Lists  
  2. Linked List Implementation | Part 1  
  3. Linked List Implementation | Part 2  
  4. Static Linked List in C  
  5. Clone given Linked List  
  6. Delete Linked List  
  7. Pop operation in linked list  
  8. Insert given node into the correct sorted position in the given sorted linked list  
  9. Given a linked list, change it to be in sorted order  
  10. Split the nodes of the given linked list into front and back halves  
  11. Remove duplicates from a sorted linked list  
  12. Move front node of the given list to the front of the another list  
  13. Move even nodes to the end of the list in reverse order  
  14. Split given linked list into two lists where each list containing alternating elements from it  
  15. Construct a linked list by merging alternate nodes of two given lists  
  16. Merge Sort Algorithm for Singly Linked List  
  17. Merge two sorted linked lists into one  
  18. Merge K sorted linked lists  
  19. Intersection of two given sorted linked lists  
  20. Reverse linked list | Part 1 (Iterative Solution)  
  21. Reverse linked list | Part 2 (Recursive Solution)  
  22. Reverse every group of k nodes in given linked list  
  23. Find K’th node from the end in a linked list  
  24. Merge alternate nodes of two linked lists into the first list  
  25. Merge two sorted linked lists from their end  
  26. Delete every N nodes in a linked list after skipping M nodes  
  27. Rearrange linked list in specific manner in linear time  
  28. Check if linked list is palindrome or not  
  29. Move last node to front in a given Linked List  
  30. Rearrange the linked list in specific manner  
  31. Detect Cycle in a linked list (Floyd’s Cycle Detection Algorithm)  
  32. Sort linked list containing 0’s, 1’s and 2’s  
  33. Stack Implementation using Linked List  
  34. Queue Implementation using Linked List  
  35. Remove duplicates from a linked list  
  36. Rearrange the linked list so that it has alternating high, low values  
  37. Rearrange a Linked List by Separating Odd Nodes from the Even Ones  
  38. Calculate height of a binary tree with leaf nodes forming a circular doubly linked list  
  39. XOR Linked List: Overview and Implementation  
  40. Convert a multilevel linked list to a singly linked list  
  41. Recursively check if linked list of characters is palindrome or not  
  42. Merge two BSTs into a doubly linked list in sorted order  
  43. Remove redundant nodes from a path formed by a linked list  
  44. Add a single-digit number to a linked list representing a number  
  45. Reverse every alternate group of k nodes in a linked list  
  46. Determine if a given linked list is a palindrome or not  
  47. Sort a Doubly Linked List using Merge Sort  
  48. Reverse a Doubly Linked List  
  49. Pairwise swap adjacent nodes of a linked list  
  50. Flatten a linked list  
  51. Check if a linked list of strings is palindromic  
  52. Flatten a multilevel linked list  
  53. Construct a height-balanced BST from an unbalanced BST  
  54. Swap K'th node from beginning with K'th node from end in a Linked List  
  55. Add two linked lists without using any extra space  
  56. Clone a Linked List with Random Pointers  
  57. Update random pointer for each linked list node to point to the maximum node  
  58. Link nodes present in each level of a binary tree in the form of a linked list  
  59. Convert a Ternary Tree to a Doubly Linked List  
  60. Print nodes of a given binary tree in vertical order  
  61. Convert a binary tree into a doubly linked list in spiral order  

Matrix

  1. Print Matrix in Spiral Order  
  2. Create Spiral Matrix from given array  
  3. Shift all matrix elements by 1 in Spiral Order  
  4. Find Shortest path from source to destination in a matrix that satisfies given constraints  
  5. Change all elements of row i and column j in a matrix to 0 if cell (i, j) has value 0  
  6. Print diagonal elements of the matrix having positive slope  
  7. Find all paths from first cell to last cell of a matrix  
  8. Replace all occurrences of 0 that are not surrounded by 1 in a binary matrix  
  9. In-place rotate the matrix by 90 degrees in clock-wise direction  
  10. Count negative elements present in sorted matrix in linear time  
  11. Report all occurrences of an element in row wise and column wise sorted matrix in linear time  
  12. Calculate sum of all elements in a sub-matrix in constant time  
  13. Find maximum sum K x K sub-matrix in a given M x N matrix  
  14. Find maximum sum submatrix present in a given matrix  
  15. Find probability that a person is alive after taking N steps on the island  
  16. Count the number of islands  
  17. Flood fill Algorithm  
  18. Find shortest safe route in a field with sensors present  
  19. Find all occurrences of given string in a character matrix  
  20. Shortest path in a Maze | Lee algorithm  
  21. Check if given matrix is Toeplitz matrix or not  
  22. In-place rotate the matrix by 180 degrees  
  23. Fill Binary Matrix with Alternating Rectangles of 0 and 1  
  24. Find all common elements present in every row of given matrix  
  25. Construct a Binary Tree from Ancestor Matrix  
  26. Find common elements present in all rows of a matrix  
  27. Find index of the row containing maximum number of 1's in a binary matrix  
  28. Generate list of possible words from a character matrix  
  29. Find the largest square sub-matrix which is surrounded by all 1's  
  30. Sort an array using Young tableau  
  31. Young Tableau | Insert, Search, Extract-Min, Delete, Replace  
  32. Find minimum passes required to convert all negative values in the matrix  
  33. Collect maximum points in a matrix by satisfying given constraints  
  34. Count number of paths in a matrix with given cost to reach destination cell  
  35. Find longest sequence formed by adjacent numbers in the matrix  
  36. Find the minimum cost to reach last cell of the matrix from its first cell  
  37. Ways to reach the bottom-right corner of a matrix with exactly k turns allowed  
  38. Matrix Chain Multiplication  
  39. Find size of largest square sub-matrix of 1’s present in given binary matrix  
  40. Chess Knight Problem – Find Shortest path from source to destination  
  41. Find Duplicate rows in a binary matrix  
  42. Print all possible solutions to N Queens problem  
  43. Print all Possible Knight’s Tours in a chessboard  
  44. Find Shortest Path in Maze  
  45. Find Longest Possible Route in a Matrix  
  46. Find total number of unique paths in a maze from source to destination  
  47. Calculate size of the largest plus of 1's in binary matrix  
  48. Find the maximum value of M[c][d] – M[a][b] over all choices of indexes  
  49. Find shortest distance of every cell from landmine in a Maze  
  50. Find shortest route in a device to construct the given string  
  51. Travelling Salesman Problem using Branch and Bound  
  52. Calculate minimum cost to reach destination city from source city  

Queue

  1. Queue Implementation  
  2. Queue Implementation using Linked List  
  3. Implement Stack using Queue Data Structure  
  4. Implement a Queue using Stack Data Structure  
  5. Efficiently print all nodes between two given levels in a binary tree  
  6. Chess Knight Problem – Find Shortest path from source to destination  
  7. Shortest path in a Maze | Lee algorithm  
  8. Find shortest safe route in a field with sensors present  
  9. Flood fill Algorithm  
  10. Count the number of islands  
  11. Find Shortest path from source to destination in a matrix that satisfies given constraints  
  12. Generate binary numbers between 1 to N  
  13. Calculate height of a binary tree | Iterative & Recursive  
  14. Delete given Binary Tree | Iterative & Recursive  
  15. Level Order Traversal of Binary Tree  
  16. Spiral Order Traversal of Binary Tree  
  17. Reverse Level Order Traversal of Binary Tree  
  18. Print all nodes of a given binary tree in specific order  
  19. Print left view of binary tree  
  20. Find next node in same level for given node in a binary tree  
  21. Check if given binary tree is complete binary tree or not  
  22. Print Diagonal Traversal of Binary Tree  
  23. Print corner nodes of every level in binary tree  
  24. Invert given Binary Tree | Recursive and Iterative solution  
  25. Find minimum passes required to convert all negative values in the matrix  
  26. Convert a binary tree into a doubly linked list in spiral order  
  27. Check if a binary tree is a min-heap or not  
  28. Invert alternate levels of a perfect binary tree  
  29. Convert a Binary Search Tree into a Min Heap  
  30. Minimum number of throws required to win Snake and Ladder game  
  31. Find shortest distance of every cell from landmine in a Maze  
  32. Convert a multilevel linked list to a singly linked list  
  33. Breadth First Search (BFS) | Iterative & Recursive Implementation  
  34. Check if an undirected graph contains cycle or not  
  35. Find maximum cost path in graph from given source to destination  
  36. Total number of paths in given digraph from given source to destination having exactly m edges  
  37. Least cost path in given digraph from given source to destination having exactly m edges  

Sorting

  1. Insertion sort | Iterative & Recursive  
  2. Selection sort | Iterative & Recursive  
  3. Bubble sort | Iterative & Recursive  
  4. Merge Sort Algorithm  
  5. Iterative Merge Sort Algorithm (Bottom-up Merge Sort)  
  6. Quicksort Algorithm  
  7. Iterative Implementation of Quicksort  
  8. Hybrid Quicksort  
  9. Quicksort using Dutch National Flag Algorithm  
  10. Quick Sort using Hoare’s Partitioning scheme  
  11. External merge sort  
  12. Counting Sort Algorithm  
  13. Custom Sort | Sort elements by their frequency and Index  
  14. Custom Sort | Sort elements of the array by order of elements defined by the second array  
  15. Inversion Count of an array  
  16. Segregate positive and negative integers in linear time  
  17. Efficiently Sort an Array with many Duplicated Values  
  18. Sort an array using Young tableau  
  19. Problems solved using partitioning logic of quicksort  
  20. Find the smallest window in array sorting which will make the entire array sorted  
  21. Find largest number possible from set of given numbers  
  22. Move all zeros present in the array to the end  
  23. Sort binary array in linear time  
  24. Sort linked list containing 0’s, 1’s and 2’s  
  25. Merge Sort Algorithm for Singly Linked List  
  26. Sort a Doubly Linked List using Merge Sort  
  27. Group anagrams together from given list of words  
  28. Activity Selection Problem  
  29. Lexicographic sorting of given set of keys  
  30. Heap Sort Algorithm  
  31. Merge M sorted lists of variable length  
  32. Merge M sorted lists each containing N elements  
  33. Find all palindromic permutations of a string  
  34. Find all lexicographically next permutations of a string sorted in ascending order  
  35. Merge two sorted linked lists from their end  
  36. Sort an array containing 0’s, 1’s and 2’s (Dutch national flag problem)  
  37. Find pair with given sum in the array  
  38. In place merge two sorted arrays  
  39. Merge two arrays by satisfying given constraints  
  40. Find maximum product of two integers in an array  
  41. Find all distinct combinations of given length  
  42. Find all distinct combinations of given length with repetition allowed  
  43. Merging Overlapping Intervals  
  44. Print all quadruplets with given sum | 4-sum problem extended  
  45. 4 sum problem | Quadruplets with given sum  
  46. Find two numbers with maximum sum formed by array digits  
  47. Find a Triplet having Maximum Product in an Array  
  48. Find Minimum Product among all Combinations of Triplets in an Array  
  49. Find all distinct combinations of given length - Part 2  
  50. Find the surpasser count for each element of an array  
  51. Segregate positive and negative integers using Merge Sort  

Stack

  1. Stack Implementation  
  2. Stack Implementation using Linked List  
  3. Check if given expression is balanced expression or not  
  4. Find duplicate parenthesis in an expression  
  5. Evaluate given postfix expression  
  6. Decode the given sequence to construct minimum number without repeated digits  
  7. Design a stack which returns minimum element in constant time  
  8. Design a stack which returns minimum element without using auxiliary stack  
  9. Reverse a string without using recursion  
  10. Implement Stack using Queue Data Structure  
  11. Implement a Queue using Stack Data Structure  
  12. Implement two stacks in a single array  
  13. Recursive solution to sort a stack  
  14. Reverse a string using stack data structure    
  15. Find all elements in an array that are greater than all elements present to their right  
  16. Inorder Tree Traversal | Iterative & Recursive  
  17. Preorder Tree Traversal | Iterative & Recursive  
  18. Postorder Tree Traversal | Iterative & Recursive  
  19. Find preorder traversal of a binary tree from its inorder and postorder sequence  
  20. Find ancestors of given node in a Binary Tree  
  21. Check if two given binary trees are identical or not | Iterative & Recursive  
  22. Reverse Level Order Traversal of Binary Tree  
  23. Reverse given text without reversing the individual words  
  24. Find all binary strings that can be formed from given wildcard pattern  
  25. Iterative Implementation of Quicksort  
  26. Depth First Search (DFS) | Iterative & Recursive Implementation  
  27. Invert given Binary Tree | Recursive and Iterative solution  
  28. Print leaf to root path for every leaf node in a binary tree  
  29. Longest Increasing Subsequence  
  30. Invert alternate levels of a perfect binary tree  

String

  1. Check if given string is a rotated palindrome or not  
  2. Longest Palindromic Substring (Non-DP Space Optimized Solution)  
  3. Check if repeated subsequence is present in the string or not  
  4. Check if strings can be derived from each other by circularly rotating them  
  5. Check if given set of moves is circular or not  
  6. Convert given number into corresponding excel column name  
  7. Determine if two strings are anagram or not  
  8. Find all binary strings that can be formed from given wildcard pattern  
  9. Find all interleaving of given strings  
  10. Isomorphic Strings  
  11. Find all possible palindromic substrings in a string  
  12. Find all possible combinations of words formed from mobile keypad  
  13. Find all possible combinations by replacing given digits with characters of the corresponding list  
  14. Find all words from given list that follows same order of characters as given pattern  
  15. Find first k non-repeating characters in a string in single traversal  
  16. Group anagrams together from given list of words  
  17. Introduction to Pattern Matching  
  18. In place remove all occurrences of ‘AB’ and ‘C’ from the string  
  19. Longest even length palindromic sum substring  
  20. Print string in zig-zag form in k rows  
  21. Reverse given text without reversing the individual words  
  22. Run Length Encoding (RLE) data compression algorithm  
  23. Validate an IP address  
  24. Find the longest substring of given string containing k distinct characters  
  25. Find all palindromic permutations of a string  
  26. Find all substrings of a string that are permutation of a given string  
  27. Find the longest substring of given string containing all distinct characters  
  28. Find all Permutations of a given string  
  29. Iterative Approach to find Permutations of a String  
  30. Generate all Permutations of a String in Java | Recursive & Iterative  
  31. Find all lexicographically next permutations of a string sorted in ascending order  
  32. Find Lexicographically minimal string rotation  
  33. Find all strings of given length containing balanced parentheses  
  34. Find all N-digit strictly increasing numbers (Bottom-Up and Top-Down Approach)  
  35. Find all N-digit binary numbers having more 1’s than 0’s for any prefix  
  36. Find all N-digit numbers with given sum of digits  
  37. Find all N-digit binary numbers with k-bits set where k ranges from 1 to N  
  38. Generate binary numbers between 1 to N  
  39. Find all combinations of non-overlapping substrings of a string  
  40. Check if given sentence is syntactically correct or not  
  41. Calculate rank of given string among all its lexicographically sorted permutations  
  42. Find all Lexicographic Permutations of a String  
  43. Find all N-digit binary numbers with equal sum of bits in its two halves  
  44. Check if given string is interleaving of two other given strings  
  45. Difference between Subarray, Subsequence and Subset  
  46. std::next_permutation | Overview & Implementation in C++  
  47. std::prev_permutation | Overview & Implementation in C++  
  48. Implementation of KMP Algorithm  
  49. Reverse String without using Recursion  
  50. Reverse given string using Recursion  
  51. Determine if a given string is palindrome or not  
  52. In-place remove all adjacent duplicates from the given string  
  53. Find the minimum number of inversions needed to make the given expression balanced  
  54. Replace all non-overlapping occurrences of the pattern  
  55. Construct the longest palindrome by shuffling or deleting characters from a string  
  56. Determine if characters of a String follow a specified order or not  
  57. Print all combinations of phrases that can be formed by picking words from each of the given lists  
  58. Remove all extra spaces from a string  
  59. Break a string into all possible combinations of non-overlapping substrings  
  60. Remove adjacent duplicate characters from a string  
  61. Find first non-repeating character in a string by doing only one traversal of it  
  62. Find all N-digit numbers with equal sum of digits at even and odd index  
  63. Find all lexicographically previous permutations of a string sorted in descending order  
  64. Combinations of words formed by replacing given numbers with corresponding alphabets  
  65. Word Break Problem  
  66. Wildcard Pattern Matching  
  67. Count number of times a pattern appears in given string as a subsequence  
  68. The Levenshtein distance (Edit distance) problem  
  69. Longest Common Subsequence | Introduction & LCS Length  
  70. Longest Common Subsequence | Space optimized version  
  71. Longest Common Subsequence of K-sequences  
  72. Longest Common Subsequence | Finding all LCS  
  73. Longest Repeated Subsequence problem  
  74. Longest Palindromic Subsequence using Dynamic Programming  
  75. Longest Common Substring problem  
  76. Shortest Common Supersequence | Introduction & SCS Length  
  77. Shortest Common Supersequence | Finding all SCS  
  78. Shortest Common Supersequence | Using LCS  
  79. Implement Diff Utility  
  80. Word Break Problem | Using Trie Data Structure  
  81. Find minimum cuts needed for palindromic partition of a string  
  82. Check if a string is K-Palindrome or not  
  83. Find shortest route in a device to construct the given string  
  84. Find minimum number possible by doing at-most K swaps  
  85. Determine if a pattern matches with a string or not  
  86. Find the correct order of alphabets in a given dictionary of ancient origin  
  87. Find minimum number of deletions required to convert a string into palindrome  

Trie

  1. Trie Implementation | Insert, Search and Delete  
  2. Memory efficient Trie Implementation using Map | Insert, Search and Delete  
  3. C++ Implementation of Trie Data Structure  
  4. Longest Common Prefix in given set of strings (using Trie)  
  5. Lexicographic sorting of given set of keys  
  6. Find maximum occurring word in given set of strings  
  7. Find first k maximum occurring words in given set of strings  
  8. Find Duplicate rows in a binary matrix  
  9. Word Break Problem | Using Trie Data Structure  
  10. Generate list of possible words from a character matrix  

Greedy

  1. Activity Selection Problem  
  2. Huffman Coding  
  3. Job Sequencing Problem with Deadlines  
  4. Greedy coloring of graph  
  5. Kruskal’s Algorithm for finding Minimum Spanning Tree  
  6. Single-Source Shortest Paths – Dijkstra’s Algorithm  
  7. Shortest Superstring Problem  

Puzzles

  1. Clock angle problem – Find angle between hour and minute hand  
  2. Add two numbers without using addition operator  
  3. Generate power set of a given set  
  4. Implement power function without using multiplication and division operators  
  5. Print all numbers between 1 to N without using semicolon  
  6. Swap two numbers without using third variable  
  7. Determine the if condition to print specific output  
  8. Find maximum, minimum of three numbers without using conditional statement and ternary operator  
  9. Find numbers represented as sum of two cubes for two different pairs  
  10. Print “Hello World” with empty main() function  
  11. Tower of Hanoi Problem  
  12. Print all numbers between 1 to N without using any loop  
  13. Print a semicolon without using semicolon anywhere in the program  
  14. Multiply two numbers without using multiplication operator or loops  
  15. Find square of a number without using multiplication and division operator  
  16. Find if a number is even or odd without using any conditional statement  
  17. Set both elements of a binary array to 0 in single line  
  18. Find minimum number without using conditional statement or ternary operator  
  19. Perform Division of two numbers without using division operator (/)  
  20. Generate 0 and 1 with 75% and 25% Probability  
  21. Generate Desired Random Numbers With Equal Probability  
  22. Return 0, 1 and 2 with equal Probability using the specified function  
  23. Generate Fair Results from a Biased Coin  
  24. Generate numbers from 1 to 7 with equal probability using specified function  
  25. Implement Ternary Operator Without Using Conditional Expressions  
  26. Determine if two integers are equal without using comparison and arithmetic operators  
  27. Return 0 and 1 with equal Probability using the specified function  
  28. Generate Random Input from an Array according to given Probabilities  
  29. Generate Fair Results from a Biased Coin  
  30. Magnet Puzzle  
Comments (4)