500+ Data Structures and Algorithms Interview Questions & Practice Problems

Vivek Srivastava
Techie Delight
28 min readJul 15, 2018

--

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. Find maximum product of two integers in an array
  9. Sort an array containing 0’s, 1’s and 2’s (Dutch National Flag Problem)
  10. In place merge two sorted arrays
  11. Merge two arrays by satisfying given constraints
  12. Find index of 0 to replace to get maximum length sequence of continuous ones
  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 (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. Longest Increasing Subsequence
  22. Find maximum difference between two elements in the array by satisfying given constraints
  23. Maximum Sum Subarray Problem (Kadane’s Algorithm)
  24. Print continuous subarray with maximum sum
  25. Maximum Sum Circular Subarray
  26. Find all distinct combinations of given length — I
  27. Find all distinct combinations of given length with repetition allowed
  28. Find maximum sequence of continuous 1’s formed by replacing at-most k zeroes by ones
  29. Find minimum sum subarray of given size k
  30. Find maximum product subarray in a given array
  31. Find subarray having given sum in given array of integers
  32. Find the length of smallest subarray whose sum of elements is greater than the given number
  33. Find largest number possible from set of given numbers
  34. Find the smallest window in array sorting which will make the entire array sorted
  35. Find maximum sum path involving elements of given arrays
  36. Maximum profit earned by buying and selling shares any number of times
  37. Trapping Rain Water within given set of bars
  38. Find minimum platforms needed in the station so to avoid any delay in arrival of any train
  39. Decode the array constructed from another array
  40. Sort an array using one swap
  41. Find Triplet with given sum in an array
  42. Length of longest continuous sequence with same sum in given binary arrays
  43. Reverse every consecutive m elements of the given subarray
  44. Maximum Product Subset Problem
  45. Find pairs with given difference k in the array
  46. Find pairs with given difference k in the array | Constant space solution
  47. 4 sum problem | Quadruplets with given sum
  48. Print all quadruplets with given sum | 4-sum problem extended
  49. Quickselect Algorithm
  50. Rearrange array such that A[A[i]] is set to i for every element A[i]
  51. Print all Triplets that forms Arithmetic Progression
  52. Print all Triplets that forms Geometric Progression
  53. Print all combination of numbers from 1 to n having sum n
  54. Replace each element of the array by its corresponding rank in the array
  55. Print all Triplets in an array with sum less than or equal to given number
  56. Group elements of an array based on their first occurrence
  57. Find minimum difference between index of two given elements present in the array
  58. Find maximum absolute difference between sum of two non-overlapping sub-arrays
  59. Find all Symmetric Pairs in an Array of Pairs
  60. Partition an array into two sub-arrays with the same sum
  61. Find count of distinct elements in every sub-array of size k
  62. Find two numbers with maximum sum formed by array digits
  63. Print all sub-arrays of an array having distinct elements
  64. Find a Triplet having Maximum Product in an Array
  65. Find Minimum Index of Repeating Element in an Array
  66. Generate random input from an array according to given probabilities
  67. Find pair in an array having minimum absolute sum
  68. Find Index of Maximum Occurring Element with Equal Probability
  69. Check if an Array is Formed by Consecutive Integers
  70. Find two non-overlapping pairs having same sum in an array
  71. Add elements of two arrays into a new array
  72. Find Minimum Product among all Combinations of Triplets in an Array
  73. Replace every element of an array with the least greater element on its right
  74. Find all odd occurring elements in an array having limited range of elements
  75. Count the distinct absolute values in the sorted array
  76. Print all combinations of positive integers in increasing order that sum to a given number
  77. Find all distinct combinations of given length — II
  78. Find subarrays with given sum in an array
  79. Find the surpasser count for each element of an array
  80. Find maximum length sequence of continuous ones (Using Sliding Window)
  81. Find maximum length sequence of continuous ones
  82. Find index that divides an array into two non-empty subarrays of equal sum
  83. Calculate frequency of all elements present in an array of specified range
  84. Rearrange the array such that it contains positive and negative numbers at alternate positions
  85. Find a sorted triplet in the given array
  86. Shuffle an array according to the given order of elements
  87. Count number of strictly increasing sub-arrays in an array
  88. Find duplicates within given range k in an array
  89. Longest Alternating Subarray Problem
  90. Find minimum range with at-least one element from each of the given arrays
  91. Find longest subsequence formed by consecutive integers
  92. Find all elements in an array that are greater than all elements present to their right
  93. Find missing number in array without using extra space
  94. Determine index of an element in given array which satisfies given constraints
  95. Find minimum moves required for converting a given array to an array of zeroes
  96. Left rotate an array
  97. Right rotate an array k times
  98. Find maximum profit earned from at most two stock transactions
  99. Find Frequency of each element in a sorted array containing duplicates
  100. Find Minimum and Maximum element in an array using minimum comparisons
  101. Difference between Subarray, Subsequence and Subset
  102. Find odd occurring element in an array in single traversal
  103. Find odd occurring element in logarithmic time
  104. Find two odd occurring elements in an array without using any extra space
  105. Check if given array represents min heap or not
  106. Find K’th smallest element in an array
  107. Find K’th largest element in an array
  108. Sort a K-Sorted Array
  109. Merge M sorted lists of variable length
  110. Find smallest range with at-least one element from each of the given lists
  111. Merge M sorted lists each containing N elements
  112. Find maximum sum of subsequence with no adjacent elements
  113. Find ways to calculate a target from elements of specified array
  114. Sort elements by their frequency and Index
  115. Sort an array based on order defined by another array
  116. Inversion Count of an array
  117. Segregate positive and negative integers in linear time
  118. Find number of rotations in a circularly sorted array
  119. Search an element in a circular sorted array
  120. Find first or last occurrence of a given number in a sorted array
  121. Count occurrences of a number in a sorted array with duplicates
  122. Find smallest missing element from a sorted array
  123. Find Floor and Ceil of a number in a sorted array
  124. Search in a nearly sorted array in logarithmic time
  125. Find number of 1’s in a sorted binary array
  126. Find Missing Term in a Sequence in Logarithmic time
  127. Find missing number and duplicate elements in an array
  128. Find the peak element in an array
  129. Find Floor and Ceil of a number in a sorted array (Recursive solution)
  130. Print all distinct subsets of a given set
  131. Find two duplicate elements in a limited range array (using XOR)
  132. Combinations of words formed by replacing given numbers with corresponding alphabets
  133. 0–1 Knapsack Problem
  134. Subset sum Problem
  135. Partition Problem
  136. 3-Partition Problem
  137. 3-partition problem extended | Print all partitions
  138. K-Partition Problem | Printing all Partitions
  139. Minimum Sum Partition Problem
  140. Rod Cutting
  141. Longest Alternating Subsequence Problem
  142. Coin change-making problem (unlimited supply of coins)
  143. Coin Change Problem — Find total number of ways to get the denomination of coins
  144. Find maximum profit earned from at most K stock transactions

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
  20. Print all shortest routes in a rectangular grid

Binary

  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. Round up to the next highest power of 2
  9. Round up to the previous power of 2
  10. Compute parity of a number using lookup table
  11. Count set bits using lookup table
  12. Find the minimum or maximum of two integers without using branching
  13. Multiply 16-bit integers using 8-bit multiplier
  14. Swap individual bits at given position in an integer
  15. Check if given number is power of 4 or not
  16. Check if given number is power of 8 or not
  17. Reverse Bits of a given Integer
  18. Find odd occurring element in an array in single traversal
  19. Find two odd occurring elements in an array without using any extra space
  20. Swap two bits at given position in an integer
  21. Add binary representation of two integers
  22. Swap Adjacent Bits of a Number
  23. Print all distinct subsets of a given set
  24. Perform Division of two numbers without using division operator (/)
  25. Check if adjacent bits are set in binary representation of a given number
  26. Conditionally negate a value without branching
  27. Find two duplicate elements in a limited range array (using XOR)
  28. Reverse Bits of an integer using lookup table
  29. Find missing number and duplicate elements in an array
  30. Circular shift on binary representation of an integer by k positions
  31. Compute modulus division without division and modulo operator
  32. Solve given set of problems without using multiplication or division operators
  33. Find XOR of two numbers without using XOR operator
  34. Generate power set of a given set
  35. Huffman Coding
  36. Find missing number in array without using extra space
  37. Find odd occurring element in logarithmic time
  38. Find all odd occurring elements in an array having limited range of elements

Binary Tree

  1. Check if two given binary trees are identical or not
  2. Calculate height of a binary tree
  3. Delete given Binary Tree
  4. Inorder Tree Traversal (Iterative & Recursive Implementation)
  5. Preorder Tree Traversal (Iterative & Recursive Implementation)
  6. Postorder Tree Traversal (Iterative & Recursive Implementation)
  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. In-place convert given binary tree to its sum tree
  17. Determine if given two nodes are cousins of each other
  18. Print cousins of given node in a binary 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. Perform vertical traversal of a binary tree — I
  32. Perform vertical traversal of a binary tree — II
  33. Print corner nodes of every level in binary tree
  34. Find the diagonal sum of given binary tree
  35. Print Diagonal Traversal of Binary Tree
  36. In-place convert Binary Tree to Doubly Linked List
  37. Sink nodes containing zero to the bottom of the binary tree
  38. Convert given binary tree to full tree by removing half nodes
  39. Truncate given binary tree to remove nodes which lie on a path having sum less than K
  40. Find maximum sum root-to-leaf path in a binary tree
  41. Check if given binary tree is height balanced or not
  42. Find maximum width of given binary tree
  43. Convert normal binary tree to Left-child right-sibling binary tree
  44. Determine if given Binary Tree is a BST or not
  45. Convert a Binary Tree to BST by maintaining its original structure
  46. Invert a Binary Tree
  47. Print Right View of a Binary Tree
  48. Print all paths from leaf to root node in given binary tree
  49. Iteratively print leaf to root path for every leaf node in a binary tree
  50. Build Binary Tree from given Parent array
  51. Find all nodes at given distance from leaf nodes in a binary tree
  52. Count all subtrees having same value of nodes in a binary tree
  53. Find Maximum Difference Between a Node and its Descendants in a Binary Tree
  54. Construct a Binary Tree from Ancestor Matrix
  55. Calculate height of a binary tree with leaf nodes forming a circular doubly linked list
  56. Find maximum sum path between two leaves in a binary tree
  57. Fix a binary tree that is only one swap away from becoming a BST
  58. Construct a binary tree from inorder and preorder traversal
  59. Construct a binary tree from inorder and postorder traversals
  60. Construct a binary tree from inorder and level order sequence
  61. Construct a full binary tree from preorder sequence with leaf node information
  62. Construct a full binary tree from a preorder and postorder sequence
  63. Set next pointer to inorder successor of all nodes in binary tree
  64. Efficiently print all nodes between two given levels in a binary tree
  65. Find preorder traversal of a binary tree from its inorder and postorder sequence
  66. Find the difference between sum of all nodes present at odd and even levels in a binary tree
  67. Find the size of the largest BST in a Binary Tree
  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. Clone a binary tree with random pointers
  72. Threaded Binary Tree: Overview and Implementation
  73. Invert alternate levels of a perfect binary tree
  74. Convert a Binary Tree into a Doubly Linked List in Spiral Order
  75. Check if a binary tree is a min-heap or not
  76. Determine if a binary tree satisfy the height-balanced property of red–black tree
  77. Depth first search (DFS) vs Breadth first search (BFS)

BST

  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
  28. Construct a Height-Balanced BST from a Sorted Doubly Linked List

Divide & Conquer

  1. Binary Search Algorithm
  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 logarithmic 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. Efficiently implement a power function
  13. Find Missing Term in a Sequence in Logarithmic time
  14. Division of Two Numbers using Binary Search Algorithm
  15. Find Floor and Ceil of a number in a sorted array (Recursive solution)
  16. Find Frequency of each element in a sorted array containing duplicates
  17. Find odd occurring element in logarithmic time
  18. Ternary Search vs Binary search
  19. Exponential search
  20. Unbounded Binary Search
  21. Interpolation search
  22. Merge Sort Algorithm
  23. QuickSort Algorithm

Dynamic Programming

  1. Introduction to Dynamic Programming
  2. Longest Common Subsequence Problem
  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 Problem
  8. Longest Repeated Subsequence Problem
  9. Implement Diff Utility
  10. Shortest Common Supersequence Problem
  11. Shortest Common Supersequence | Finding all SCS
  12. Shortest Common Supersequence Problem using LCS
  13. Longest Increasing Subsequence Problem
  14. Longest Decreasing Subsequence Problem
  15. Longest Bitonic Subsequence
  16. Increasing Subsequence with Maximum Sum
  17. The Levenshtein Distance (Edit Distance) Problem
  18. Find size of largest square sub-matrix of 1’s present in given binary matrix
  19. Matrix Chain Multiplication
  20. Find the minimum cost to reach last cell of the matrix from its first cell
  21. Find longest sequence formed by adjacent numbers in the matrix
  22. Count number of paths in a matrix with given cost to reach destination cell
  23. 0–1 Knapsack Problem
  24. Maximize value of the expression
  25. Partition Problem
  26. Subset sum Problem
  27. 3-Partition Problem
  28. Minimum Sum Partition Problem
  29. Rod Cutting
  30. Maximum Product Rod Cutting
  31. Coin change-making problem (unlimited supply of coins)
  32. Coin Change Problem — Find total number of ways to get the denomination of coins
  33. Total possible solutions to linear equation of k variables
  34. Longest Alternating Subsequence Problem
  35. Count number of times a pattern appears in given string as a subsequence
  36. Collect maximum points in a matrix by satisfying given constraints
  37. Find all N-digit binary strings without any consecutive 1’s
  38. Count total possible combinations of N-digit numbers in a mobile keypad
  39. Word Break Problem
  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
  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. Pots of Gold Game Problem
  54. Find minimum cuts needed for palindromic partition of a string
  55. Weighted Interval Scheduling using LIS algorithm
  56. Find minimum jumps required to reach the destination
  57. Find probability that a person is alive after taking N steps on the island
  58. Find maximum sum of subsequence with no adjacent elements
  59. Maximum Length Snake Sequence
  60. Calculate size of the largest plus of 1’s in binary matrix
  61. Longest Increasing Subsequence using LCS
  62. Find maximum profit earned from at most K stock transactions
  63. Count all paths in a matrix from first cell to last cell
  64. Check if a string matches with a given wildcard pattern
  65. Check if given string is interleaving of two other given strings
  66. Find all employees who directly or indirectly reports to a manager
  67. Find optimal cost to construct binary search tree
  68. Find maximum sum of subsequence with no adjacent elements
  69. Maximum Sum Subarray Problem (Kadane’s Algorithm)
  70. Longest Alternating Subarray Problem
  71. Collect maximum value of coins in a matrix
  72. Find length of longest path in the matrix with consecutive characters
  73. Find ways to calculate a target from elements of specified array
  74. Calculate sum of all elements in a sub-matrix in constant time
  75. Find maximum sum K x K sub-matrix in a given M x N matrix
  76. Find maximum sum submatrix present in a given matrix
  77. Single-Source Shortest Paths — Bellman Ford Algorithm
  78. All-Pairs Shortest Paths — Floyd Warshall Algorithm

Graph

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

Greedy

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

Heap

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

Linked List

  1. Introduction to Linked Lists
  2. Linked List Implementation — C, C++, Java, Python
  3. Linked List | Insertion at Tail
  4. Static Linked List
  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. Rearrange linked list in increasing order (Sort linked list)
  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 (Iterative Solution)
  21. Reverse Linked List (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. Implement Stack using Linked List
  34. Implement Queue 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 String 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
  62. Construct a Height-Balanced BST from a Sorted Doubly Linked List
  63. In-place merge two sorted linked lists without modifying links of the first list
  64. Reverse specified portion of a Linked List

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. Count the number of islands
  16. Flood Fill Algorithm
  17. Find shortest safe route in a field with sensors present
  18. Find all occurrences of given string in a character matrix
  19. Shortest path in a Maze | Lee Algorithm
  20. Check if given matrix is Toeplitz matrix or not
  21. In-place rotate the matrix by 180 degrees
  22. Fill Binary Matrix with Alternating Rectangles of 0 and 1
  23. Find all common elements present in every row of given matrix
  24. Construct a Binary Tree from Ancestor Matrix
  25. Find common elements present in all rows of a matrix
  26. Find index of the row containing maximum number of 1’s in a binary matrix
  27. Find the largest square sub-matrix which is surrounded by all 1's
  28. Find minimum passes required to convert all negative values in the matrix
  29. Print a spiral square matrix without using any extra space
  30. Print all shortest routes in a rectangular grid
  31. Find length of longest path in the matrix with consecutive characters
  32. Collect maximum value of coins in a matrix
  33. Young Tableau | Insert, Search, Extract-Min, Delete, Replace
  34. Sort an array using Young tableau
  35. Find path from source to destination in a matrix that satisfies given constraints
  36. Generate list of possible words from a character matrix
  37. Find probability that a person is alive after taking N steps on the island
  38. Collect maximum points in a matrix by satisfying given constraints
  39. Count number of paths in a matrix with given cost to reach destination cell
  40. Find longest sequence formed by adjacent numbers in the matrix
  41. Find the minimum cost to reach last cell of the matrix from its first cell
  42. Ways to reach the bottom-right corner of a matrix with exactly k turns allowed
  43. Matrix Chain Multiplication
  44. Find size of largest square sub-matrix of 1’s present in given binary matrix
  45. Chess Knight Problem — Find Shortest path from source to destination
  46. Find Duplicate rows in a binary matrix
  47. Print all possible solutions to N Queens Problem
  48. Print all Possible Knight’s Tours in a chessboard
  49. Find Shortest Path in Maze
  50. Find Longest Possible Route in a Matrix
  51. Find total number of unique paths in a maze from source to destination
  52. Calculate size of the largest plus of 1’s in binary matrix
  53. Find the maximum value of M[c][d] — M[a][b] over all choices of indexes
  54. Find shortest distance of every cell from landmine in a Maze
  55. Find shortest route in a device to construct the given string
  56. Calculate minimum cost to reach destination city from source city
  57. Count all paths in a matrix from first cell to last cell
  58. Merge M sorted lists each containing N elements
  59. Travelling Salesman Problem using Branch and Bound

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 triplet 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. Compute modulus division without division and modulo operator

Queue

  1. Queue Implementation using Array/List — C, C++, Java, Python
  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
  14. Delete given Binary Tree
  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 a Binary Tree
  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. Snake and Ladder Problem
  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) Algorithm
  34. Check if an undirected graph contains cycle or not
  35. Find maximum cost path in graph from given source to destination
  36. Total 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 Algorithm
  2. Selection Sort Algorithm
  3. Bubble Sort Algorithm
  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. QuickSort using Hoare’s Partitioning scheme
  11. Heap Sort Algorithm
  12. Introsort Algorithm
  13. External Merge Sort Algorithm
  14. Counting Sort Algorithm
  15. Inversion Count of an array
  16. Sort an array using Young tableau
  17. Merge Sort Algorithm for Singly Linked List
  18. Problems solved using partitioning logic of QuickSort
  19. Sort a Doubly Linked List using Merge Sort
  20. Sort elements by their frequency and Index
  21. Sort an array based on order defined by another array
  22. Efficiently sort an array with many duplicated values
  23. Find largest number possible from set of given numbers
  24. Find the surpasser count for each element of an array
  25. Segregate positive and negative integers using Merge Sort
  26. Group anagrams together from given list of words

Stack

  1. Stack Implementation using Array/List — C, C++, Java, Python
  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. Merging Overlapping Intervals
  10. Reverse String without using Recursion
  11. Implement Stack using Queue Data Structure
  12. Implement a Queue using Stack Data Structure
  13. Implement two stacks in a single array
  14. Recursive solution to sort a stack
  15. Find length of the longest balanced parenthesis in a string
  16. Reverse a string using stack data structure
  17. Find all elements in an array that are greater than all elements present to their right
  18. Inorder Tree Traversal
  19. Preorder Tree Traversal
  20. Postorder Tree Traversal
  21. Find preorder traversal of a binary tree from its inorder and postorder sequence
  22. Find ancestors of given node in a Binary Tree
  23. Check if two given binary trees are identical or not
  24. Reverse Level Order Traversal of Binary Tree
  25. Reverse given text without reversing the individual words
  26. Find all binary strings that can be formed from given wildcard pattern
  27. Iterative Implementation of QuickSort
  28. Depth First Search (DFS) Algorithm
  29. Invert a Binary Tree
  30. Print leaf to root path for every leaf node in a binary tree
  31. Longest Increasing Subsequence
  32. 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. Group anagrams together from given list of words
  16. Find minimum operations required to transform a string into another string
  17. Determine if a string can be transformed into another string with a single edit
  18. Find length of the longest balanced parenthesis in a string
  19. In place remove all occurrences of ‘AB’ and ‘C’ from the string
  20. Longest even length palindromic sum substring
  21. Print string in zig-zag form in k rows
  22. Reverse given text without reversing the individual words
  23. Run Length Encoding (RLE) Data Compression Algorithm
  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. Iterative Approach to find Permutations of a String
  29. Generate all Permutations of a String in Java
  30. Find all lexicographically next permutations of a string sorted in ascending order
  31. Find Lexicographically minimal string rotation
  32. Find all strings of given length containing balanced parentheses
  33. Find all combinations of non-overlapping substrings of a string
  34. Determine if a given string is palindrome or not
  35. Find the minimum number of inversions needed to make the given expression balanced
  36. Construct the longest palindrome by shuffling or deleting characters from a string
  37. Print all combinations of phrases formed by picking words from each of the given lists
  38. Break a string into all possible combinations of non-overlapping substrings
  39. Remove all extra spaces from a string
  40. Remove adjacent duplicate characters from a string
  41. Find first non-repeating character in a string by doing only one traversal of it
  42. Find all N-digit strictly increasing numbers (Bottom-Up and Top-Down Approach)
  43. Find all N-digit binary numbers having more 1’s than 0’s for any prefix
  44. Find all N-digit numbers with given sum of digits
  45. Find all N-digit binary numbers with k-bits set where k ranges from 1 to N
  46. Find all N-digit binary numbers with equal sum of bits in its two halves
  47. Find all N-digit numbers with equal sum of digits at even and odd index
  48. Find all Lexicographic Permutations of a String
  49. Lexicographic Rank of a String
  50. Find all lexicographically previous permutations of a string sorted in descending order
  51. Replace all non-overlapping occurrences of the pattern
  52. Introduction to Pattern Matching
  53. Implementation of KMP Algorithm
  54. Reverse String without using Recursion
  55. Reverse given string using Recursion
  56. Determine if characters of a String follow a specified order or not
  57. In-place remove all adjacent duplicates from the given string
  58. Check if given sentence is syntactically correct or not
  59. Find all Permutations of a given string
  60. Find first k non-repeating characters in a string in single traversal
  61. Check if given string is interleaving of two other given strings
  62. Decode the given sequence to construct minimum number without repeated digits
  63. Combinations of words formed by replacing given numbers with corresponding alphabets
  64. Count number of times a pattern appears in given string as a subsequence
  65. Check if a string matches with a given wildcard pattern
  66. Find all words matching a pattern in the given dictionary
  67. The Levenshtein Distance (Edit Distance) Problem
  68. Longest Common Subsequence Problem
  69. Longest Repeated Subsequence Problem
  70. Longest Palindromic Subsequence using Dynamic Programming
  71. Longest Common Substring Problem
  72. Shortest Common Supersequence Problem
  73. Word Break Problem
  74. Wildcard Pattern Matching
  75. Find minimum cuts needed for palindromic partition of a string
  76. Check if a string is K-Palindrome or not
  77. Find shortest route in a device to construct the given string
  78. Find minimum number possible by doing at-most K swaps
  79. Determine if a pattern matches with a string or not
  80. Find minimum number of deletions required to convert a string into palindrome

Trie

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

--

--