Data Structures and Algorithms Problems




 

  1. 1. Find a pair with the given sum in an arrayEasy
  2. 2. Check if a subarray with 0 sum exists or notMedium
  3. 3. Print all subarrays with 0 sumMedium
  4. 4. Sort binary array in linear timeEasy
  5. 5. Find maximum length subarray having a given sumMedium
  6. 6. Find the largest subarray having an equal number of 0’s and 1’sMedium
  7. 7. Find the maximum product of two integers in an arrayEasy
  8. 8. Sort an array of 0’s, 1’s, and 2’s (Dutch National Flag Problem)Medium
  9. 9. In-place merge two sorted arraysMedium
  10. 10. Merge two arrays by satisfying given constraintsMedium
  11. 11. Find index of 0 to be replaced to get the maximum length sequence of continuous onesHard
  12. 12. Shuffle an array using Fisher–Yates shuffle algorithmMedium
  13. 13. Rearrange an array with alternate high and low elementsMedium
  14. 14. Find equilibrium index of an arrayEasy
  15. 15. Find the largest subarray formed by consecutive integersMedium
  16. 16. Boyer–Moore Majority Vote AlgorithmEasy
  17. 17. Move all zeros present in an array to the endEasy
  18. 18. Replace every array element with the product of every other elementMedium
  19. 19. Longest Bitonic Subarray ProblemMedium
  20. 20. Find maximum difference between two array elements that satisfies given constraintsMedium
  21. 21. Maximum Sum Subarray Problem (Kadane’s Algorithm)Easy
  22. 22. Print continuous subarray with maximum sumMedium
  23. 23. Maximum Sum Circular SubarrayHard
  24. 24. Find all distinct combinations of a given length – IMedium
  25. 25. Find all distinct combinations of a given length – IIMedium
  26. 26. Find maximum sequence of continuous 1’s formed by replacing at-most k 0’s by 1’sMedium
  27. 27. Find minimum sum subarray of size kMedium
  28. 28. Maximum Product Subarray ProblemHard
  29. 29. Find a subarray having the given sum in an integer arrayMedium
  30. 30. Find the smallest subarray length whose sum of elements is greater than kMedium
  31. 31. Find the smallest window in an array sorting which will make the entire array sortedMedium
  32. 32. Find maximum sum path involving elements of given arraysMedium
  33. 33. Find maximum profit earned by buying and selling shares any number of timesMedium
  34. 34. Trapping Rain Water ProblemHard
  35. 35. Find minimum platforms needed to avoid delay in the train arrivalMedium
  36. 36. Decode an array constructed from another arrayMedium
  37. 37. Sort an array in one swap whose two elements are swappedEasy
  38. 38. Find a triplet with the given sum in an arrayMedium
  39. 39. Find the longest continuous sequence length with the same sum in given binary arraysHard
  40. 40. Reverse every consecutive m-elements of a subarrayMedium
  41. 41. Maximum Product Subset ProblemEasy
  42. 42. Find pairs with difference k in an arrayEasy
  43. 43. 4–Sum Problem | Quadruplets with a given sumMedium
  44. 44. Print all quadruplets with a given sum | 4 sum problem extendedMedium
  45. 45. Count quadruplets with a zero sumMedium
  46. 46. Quickselect AlgorithmMedium
  47. 47. Rearrange array such that A[A[i]] is set to i for every element A[i]Hard
  48. 48. Print all triplets that form an arithmetic progressionMedium
  49. 49. Print all triplets that form a geometric progressionMedium
  50. 50. Group elements of an array based on their first occurrenceMedium
  51. 51. Find minimum difference between the index of two given elements present in an arrayEasy
  52. 52. Find maximum absolute difference between the sum of two non-overlapping subarraysHard
  53. 53. Find all symmetric pairs in an array of pairsMedium
  54. 54. Find the closest pair to a given sum in two sorted arraysMedium
  55. 55. Partition an array into two subarrays with the same sumEasy
  56. 56. Find the count of distinct elements in every subarray of size kMedium
  57. 57. Find two numbers with maximum sum formed by array digitsEasy
  58. 58. Print all subarrays of an array having distinct elementsMedium
  59. 59. Find a triplet having the maximum product in an arrayMedium
  60. 60. Find the minimum index of a repeating element in an arrayEasy
  61. 61. Find a pair with a minimum absolute sum in an arrayEasy
  62. 62. Find an index of the maximum occurring element with equal probabilityEasy
  63. 63. Check if an array is formed by consecutive integersMedium
  64. 64. Find two non-overlapping pairs having the same sum in an arrayMedium
  65. 65. Add elements of two arrays into a new arrayEasy
  66. 66. Find minimum product among all combinations of triplets in an arrayMedium
  67. 67. Count distinct absolute values in a sorted arrayMedium
  68. 68. Print all combinations of positive integers in increasing order that sums to a numberHard
  69. 69. Find subarrays with a given sum in an arrayMedium
  70. 70. Find maximum length sequence of continuous ones (Using Sliding Window)Medium
  71. 71. Find maximum length sequence of continuous onesMedium
  72. 72. Find the index that divides an array into two non-empty subarrays with equal sumEasy
  73. 73. Efficiently calculate the frequency of all elements present in a limited range arrayMedium
  74. 74. Rearrange an array such that it contains alternate positive and negative numbersMedium
  75. 75. Find the sorted triplet in an arrayMedium
  76. 76. Shuffle an array according to the given order of elementsMedium
  77. 77. Count the number of strictly increasing subarrays in an arrayMedium
  78. 78. Find duplicates within a range k in an arrayEasy
  79. 79. Find a minimum range with at least one element from each of the given arraysHard
  80. 80. Find the longest subsequence formed by consecutive integersMedium
  81. 81. Determine the index of an element that satisfies given constraints in an arrayEasy
  82. 82. Find minimum moves required for converting a given array to an array of zeroesMedium
  83. 83. Left rotate an arrayEasy
  84. 84. Right rotate an array k timesEasy
  85. 85. Activity Selection ProblemEasy
  86. 86. Job Sequencing Problem with DeadlinesMedium
  87. 87. 3–partition problem extended | Printing all partitionsHard
  88. 88. Count triplets which form an inversion in an arrayEasy
  89. 89. Determine whether an array can be divided into pairs with a sum divisible by kMedium
  90. 90. Find minimum removals required in an array to satisfy given constraintsMedium
  91. 91. Find a pair with the given sum in a circularly sorted arrayMedium
  92. 92. Segregate positive and negative integers in linear timeEasy
  93. 93. Find all distinct combinations of a given length that sum to a targetMedium
  94. 94. Find all duplicate elements in a limited range arrayEasy
  95. 95. Find the minimum and maximum element in an array using minimum comparisonsMedium
  96. 96. Insertion Sort AlgorithmEasy
  97. 97. Selection Sort AlgorithmEasy
  98. 98. Bubble Sort AlgorithmEasy
  99. 99. Merge Sort AlgorithmEasy
  100. 100. Iterative Merge Sort Algorithm (Bottom-up Merge Sort)Medium
  101. 101. Quicksort AlgorithmMedium
  102. 102. Hybrid QuickSort AlgorithmMedium
  103. 103. Quicksort using Dutch National Flag AlgorithmMedium
  104. 104. Quicksort algorithm using Hoare’s partitioning schemeMedium
  105. 105. Counting Sort AlgorithmEasy
  106. 106. In-place vs out-of-place algorithmsBeginner
  107. 107. Inversion count of an arrayHard
  108. 108. Problems solved using partitioning logic of QuicksortEasy
  109. 109. Sort elements by their frequency and indexMedium
  110. 110. Sort an array based on order defined by another arrayMedium
  111. 111. Efficiently sort an array with many duplicated valuesMedium
  112. 112. Find the largest number possible from a given set of numbersMedium
  113. 113. Find surpasser count for each array elementHard
  114. 114. Segregate positive and negative integers using merge sortMedium
  115. 115. How to Boost QuickSort Performance?Easy
  116. 116. Water Jugs ProblemHard
  117. 117. Print matrix in spiral orderMedium
  118. 118. Create a spiral matrix from a given arrayMedium
  119. 119. Shift all matrix elements by 1 in spiral orderMedium
  120. 120. Change all elements of row i and column j in a matrix to 0 if cell (i, j) is 0Medium
  121. 121. Print diagonal elements of a matrix having a positive slopeMedium
  122. 122. Replace all occurrences of 0 that are not surrounded by 1 in a binary matrixMedium
  123. 123. In-place rotate matrix by 90 degrees in a clockwise directionEasy
  124. 124. Count negative elements present in the sorted matrix in linear timeEasy
  125. 125. Report all occurrences of an element in a row-wise and column-wise sorted matrixMedium
  126. 126. Check if a matrix is a Toeplitz or notEasy
  127. 127. In-place rotate matrix by 180 degreesMedium
  128. 128. Fill binary matrix with alternating rectangles of 0 and 1Medium
  129. 129. Find all common elements present in each row of a matrixMedium
  130. 130. Find common elements present in all rows of a matrixMedium
  131. 131. Find the index of a row containing the maximum number of 1’s in a binary matrixHard
  132. 132. Find the largest square submatrix which is surrounded by all 1’sMedium
  133. 133. Print a spiral square matrix without using any extra spaceHard
  134. 134. Young Tableau | Insert, Search, Extract-Min, Delete, ReplaceHard
  135. 135. Replace all occurrences of 0 that are surrounded by 1 in a binary matrixMedium
  136. 136. Find the area of the largest rectangle of 1’s in a binary matrixHard
  137. 137. Find maximum value of M[c][d] – M[a][b] over all choices of indexesMedium
  138. 138. Generate pascal triangle of the given sizeEasy
  139. 139. Find perimeter of an IslandEasy
  140. 140. Find kth smallest value in a sorted matrixMedium
  141. 141. Sort an array using Young tableauHard
  142. 142. Print all possible solutions to N–Queens problemHard
  143. 143. Print all possible Knight’s tours on a chessboardHard
  144. 144. Find the shortest path in a mazeMedium
  145. 145. Find the longest possible route in a matrixMedium
  146. 146. Find the path from source to destination in a matrix that satisfies given constraintsMedium
  147. 147. Find the total number of unique paths in a maze from source to destinationMedium
  148. 148. Find all combinations of elements satisfying given constraintsMedium
  149. 149. K–Partition Problem | Printing all partitionsHard
  150. 150. Magnet PuzzleHard
  151. 151. Find all paths from the first cell to the last cell of a matrixMedium
  152. 152. Print all shortest routes in a rectangular gridMedium
  153. 153. Find all distinct combinations of a given length with repetition allowedMedium
  154. 154. Print all combinations of numbers from 1 to n having sum nMedium
  155. 155. Print all triplets in an array with a sum less than or equal to a given numberMedium
  156. 156. Check if a string is a rotated palindrome or notMedium
  157. 157. Longest Palindromic Substring ProblemMedium
  158. 158. Check if a repeated subsequence is present in a string or notHard
  159. 159. Check if strings can be derived from each other by circularly rotating themEasy
  160. 160. Check if a set of moves is circular or notMedium
  161. 161. Convert a number into a corresponding excel column nameMedium
  162. 162. Convert column name in Excel to the corresponding numberEasy
  163. 163. Find all interleaving of given stringsEasy
  164. 164. Isomorphic StringsMedium
  165. 165. Remove all extra spaces from a stringMedium
  166. 166. Find all possible palindromic substrings of a stringHard
  167. 167. Find all possible combinations of words formed from the mobile keypadHard
  168. 168. Find all combinations by replacing given digits with corresponding list charactersHard
  169. 169. Find all words that follow the same order of characters as given patternMedium
  170. 170. Group anagrams together from a list of wordsMedium
  171. 171. Find minimum operations required to transform a string into another stringHard
  172. 172. Determine whether a string can be transformed into another string in a single editMedium
  173. 173. Remove all occurrences of AB and C from a stringEasy
  174. 174. Find the longest even-length palindromic sum substring of a stringMedium
  175. 175. Print string in the zigzag form in k rowsMedium
  176. 176. Run Length Encoding (RLE) Data Compression AlgorithmEasy
  177. 177. Find the longest substring of a string containing k distinct charactersHard
  178. 178. Find all palindromic permutations of a stringMedium
  179. 179. Find all substrings of a string that are a permutation of another stringMedium
  180. 180. Find the longest substring of a string containing distinct charactersMedium
  181. 181. Find all permutations of a string – C++, Java, PythonHard
  182. 182. Iterative approach to finding permutations of a stringHard
  183. 183. Find all lexicographically next permutations of a stringHard
  184. 184. Lexicographically Minimal String RotationMedium
  185. 185. Find all strings of a given length containing balanced parenthesesMedium
  186. 186. Find all combinations of non-overlapping substrings of a stringMedium
  187. 187. Determine whether a string is a palindrome or notEasy
  188. 188. Find the minimum number of inversions needed to make an expression balancedMedium
  189. 189. Construct the longest palindrome by shuffling or deleting characters from a stringMedium
  190. 190. Print all combinations of phrases formed by picking words from each of the given listsMedium
  191. 191. Break a string into all possible combinations of non-overlapping substringsMedium
  192. 192. Convert a Roman numeral to an IntegerEasy
  193. 193. Remove adjacent duplicate characters from a stringEasy
  194. 194. Find the first non-repeating character in a string by doing only one traversal of itMedium
  195. 195. Find all n-digit strictly increasing numbers (Bottom-up and Top-down approach)Medium
  196. 196. Find all n-digit binary numbers having more 1’s than 0’s for any prefixMedium
  197. 197. Find all n-digit numbers with a given sum of digitsHard
  198. 198. Find all n-digit binary numbers with k-bits set where k ranges from 1 to nHard
  199. 199. Find all n-digit binary numbers with an equal sum of bits in their two halvesHard
  200. 200. Find all n-digit numbers with equal sum of digits at even and odd indicesHard
  201. 201. Find all lexicographic permutations of a stringHard
  202. 202. Determine if a string is a subsequence of another stringEasy
  203. 203. Find all lexicographically previous permutations of a stringHard
  204. 204. Replace all non-overlapping occurrences of a patternMedium
  205. 205. Find all substrings containing exactly k distinct charactersMedium
  206. 206. Introduction to Pattern MatchingBeginner
  207. 207. KMP AlgorithmHard
  208. 208. Reverse a string using recursionEasy
  209. 209. Determine whether the characters of a string follow a specified order or notMedium
  210. 210. Check if a sentence is syntactically correct or notMedium
  211. 211. Check a string for repeated substringsEasy
  212. 212. Find difference between two stringsEasy
  213. 213. Construct smallest number after removing k digits from a stringMedium
  214. 214. Number to word conversionHard
  215. 215. Find all occurrences of the given string in a character matrixHard
  216. 216. Shortest Superstring ProblemHard
  217. 217. Find the shortest route in a device to construct a given stringMedium
  218. 218. Find the minimum number possible by doing at-most k swapsMedium
  219. 219. Determine whether a string matches with a given patternHard
  220. 220. Difference between Subarray, Subsequence, and SubsetBeginner
  221. 221. Determine whether two strings are anagram or notEasy
  222. 222. Bit Hacks – Part 1 (Basic)Easy
  223. 223. Bit Hacks – Part 2 (Playing with k’th bit)Easy
  224. 224. Bit Hacks – Part 3 (Playing with the rightmost set bit of a number)Easy
  225. 225. Bit Hacks – Part 4 (Playing with letters of the English alphabet)Easy
  226. 226. Bit Hacks – Part 5 (Find the absolute value of an integer without branching)Easy
  227. 227. Find the total number of bits needed to be flippedEasy
  228. 228. Brian Kernighan’s Algorithm to count set bits in an integerEasy
  229. 229. Round up to the next highest power of 2Medium
  230. 230. Round up to the previous power of 2Medium
  231. 231. Compute the parity of a number using a lookup tableHard
  232. 232. Count set bits using a lookup tableHard
  233. 233. Multiply 16-bit integers using an 8-bit multiplierMedium
  234. 234. Swap two bits at a given position in an integerMedium
  235. 235. Swap individual bits at a given position in an integerHard
  236. 236. Check if a number is a power of 4 or notMedium
  237. 237. Calculate hamming distance between two integersEasy
  238. 238. Generate an array with the set bit count of each indexEasy
  239. 239. Reverse bits of an integerMedium
  240. 240. Print binary representation of a numberEasy
  241. 241. Add binary representation of two integersEasy
  242. 242. Swap adjacent bits of a numberMedium
  243. 243. Check if adjacent bits are set in the binary representation of a numberEasy
  244. 244. Reverse bits of an integer using a lookup tableHard
  245. 245. Circular shift on the binary representation of an integer by k positionsMedium
  246. 246. Find XOR of two numbers without using the XOR operatorMedium
  247. 247. Print all distinct subsets of a given setHard
  248. 248. Find the missing number in an arrayEasy
  249. 249. Find the missing number in an array without using any extra spaceEasy
  250. 250. Find the odd occurring element in an array in a single traversalEasy
  251. 251. Find two odd occurring elements in an array without using any extra spaceMedium
  252. 252. Find all odd occurring elements in an array having a limited range of elementsMedium
  253. 253. Find the duplicate element in a limited range arrayMedium
  254. 254. Find two duplicate elements in a limited range array (using XOR)Medium
  255. 255. Find the missing number and duplicate elements in an arrayMedium
  256. 256. Stack implementation using an array – C, C++, C++ (Using Templates), Java, PythonBeginner
  257. 257. Check if an expression is balanced or notEasy
  258. 258. Find duplicate parenthesis in an expressionMedium
  259. 259. Evaluate a postfix expressionEasy
  260. 260. Decode a given sequence to construct a minimum number without repeated digitsHard
  261. 261. Design a stack that returns the minimum element in constant timeHard
  262. 262. Design a stack that returns a minimum element without using an auxiliary stackHard
  263. 263. Merging Overlapping IntervalsMedium
  264. 264. Maximum Overlapping Intervals ProblemMedium
  265. 265. Insert an interval by merging overlapping intervalsMedium
  266. 266. Convert an infix expression into a postfix expressionMedium
  267. 267. Implement two stacks in a single arrayEasy
  268. 268. Recursive solution to sort a stackHard
  269. 269. Reverse a stack using recursionHard
  270. 270. Reverse a string using a stack data structureEasy
  271. 271. Find the next greater element for every array elementMedium
  272. 272. Find the next greater element for every element in a circular arrayHard
  273. 273. Find the previous smaller element for each array elementMedium
  274. 274. Reverse an array in C++Easy
  275. 275. Longest Increasing Subsequence ProblemHard
  276. 276. Find all increasing subsequences of an arrayMedium
  277. 277. Find all elements in an array that are greater than all elements to their rightEasy
  278. 278. Iterative Implementation of QuicksortMedium
  279. 279. Find all binary strings that can be formed from a wildcard patternMedium
  280. 280. Find the length of the longest balanced parenthesis in a stringHard
  281. 281. Reverse text without reversing individual wordsMedium
  282. 282. Evaluate a given expressionHard
  283. 283. Reverse a string without using recursionEasy
  284. 284. Construct a string from an encoded sequenceHard
  285. 285. Inorder Tree TraversalMedium
  286. 286. Preorder Tree TraversalMedium
  287. 287. Postorder Tree TraversalMedium
  288. 288. Level order traversal of a binary treeEasy
  289. 289. Check if two binary trees are identical or notEasy
  290. 290. Print bottom view of a binary treeMedium
  291. 291. Print top view of a binary treeMedium
  292. 292. Calculate the height of a binary treeEasy
  293. 293. Delete a binary treeEasy
  294. 294. Spiral order traversal of a binary treeMedium
  295. 295. Reverse level order traversal of a binary treeEasy
  296. 296. In-place convert a binary tree to its sum treeEasy
  297. 297. Determine whether the given binary tree nodes are cousins of each otherMedium
  298. 298. Print cousins of a given node in a binary treeMedium
  299. 299. Check if a binary tree is a sum tree or notMedium
  300. 300. Combinations of words formed by replacing given numbers with corresponding alphabetsHard
  301. 301. Determine whether a binary tree is a subtree of another binary treeMedium
  302. 302. Find the diameter of a binary treeMedium
  303. 303. Check if a binary tree is symmetric or notEasy
  304. 304. Convert a binary tree to its mirrorEasy
  305. 305. Determine if a binary tree can be converted to another by swapping childrenEasy
  306. 306. Find the Lowest Common Ancestor (LCA) of two nodes in a binary treeMedium
  307. 307. Print all paths from the root to leaf nodes of a binary treeEasy
  308. 308. Find ancestors of a given node in a binary treeMedium
  309. 309. Find distance between given pairs of nodes in a binary treeHard
  310. 310. Find the diagonal sum of a binary treeMedium
  311. 311. Sink nodes containing zero to the bottom of a binary treeHard
  312. 312. Convert a binary tree to a full tree by removing half nodesMedium
  313. 313. Truncate a binary tree to remove nodes that lie on a path having a sum less than kMedium
  314. 314. Find maximum sum root to leaf path in a binary treeMedium
  315. 315. Check if a binary tree is height-balanced or notMedium
  316. 316. Convert binary tree to Left-child right-sibling binary treeMedium
  317. 317. Print all paths from leaf to root node of a binary treeMedium
  318. 318. Iteratively print the leaf to root path for every leaf node in a binary treeMedium
  319. 319. Build a binary tree from a parent arrayHard
  320. 320. Find all nodes at a given distance from leaf nodes in a binary treeHard
  321. 321. Count all subtrees having the same value of nodes in a binary treeMedium
  322. 322. Find the maximum difference between a node and its descendants in a binary treeMedium
  323. 323. Find the maximum sum path between two leaves in a binary treeHard
  324. 324. Construct a binary tree from inorder and preorder traversalHard
  325. 325. Construct a binary tree from inorder and postorder traversalsHard
  326. 326. Construct a binary tree from inorder and level order sequenceHard
  327. 327. Construct a full binary tree from the preorder sequence with leaf node informationHard
  328. 328. Construct a full binary tree from a preorder and postorder sequenceHard
  329. 329. Find postorder traversal of a binary tree from its inorder and preorder sequenceMedium
  330. 330. Set next pointer to the inorder successor of all nodes in a binary treeEasy
  331. 331. Find preorder traversal of a binary tree from its inorder and postorder sequenceHard
  332. 332. Find difference between sum of all nodes present at odd and even levels in a binary treeEasy
  333. 333. Clone a binary treeEasy
  334. 334. Clone a binary tree with random pointersHard
  335. 335. Threaded Binary Tree – Overview and ImplementationMedium
  336. 336. Determine if a binary tree satisfies the height-balanced property of a red–black treeMedium
  337. 337. Construct an ancestor matrix from a binary treeEasy
  338. 338. Find all possible binary trees having the same inorder traversalHard
  339. 339. Perform boundary traversal on a binary treeMedium
  340. 340. Check if binary representation of a number is palindrome or notEasy
  341. 341. Check if each node of a binary tree has exactly one childEasy
  342. 342. Evaluate a Binary Expression TreeEasy
  343. 343. Construction of an expression treeEasy
  344. 344. Fix children-sum property in a binary treeMedium
  345. 345. Maximum path sum in a binary treeHard
  346. 346. Create a mirror of an m–ary treeEasy
  347. 347. Print a two-dimensional view of a binary treeEasy
  348. 348. Construct a binary tree from an ancestor matrixHard
  349. 349. Insertion in a BSTEasy
  350. 350. Search a given key in BSTEasy
  351. 351. Deletion from BST (Binary Search Tree)Medium
  352. 352. Construct a balanced BST from the given keysEasy
  353. 353. Determine whether a given binary tree is a BST or notMedium
  354. 354. Check if the given keys represent the same BSTs or not without building BSTHard
  355. 355. Find inorder predecessor for the given key in a BSTMedium
  356. 356. Find the Lowest Common Ancestor (LCA) of two nodes in a BSTEasy
  357. 357. Find k’th smallest node in a BSTEasy
  358. 358. Find k’th largest node in a BSTEasy
  359. 359. Find floor and ceil in a Binary Search TreeMedium
  360. 360. Convert a binary tree to BST by maintaining its original structureMedium
  361. 361. Remove nodes from a BST that have keys outside a valid rangeMedium
  362. 362. Find a pair with the given sum in a BSTEasy
  363. 363. Find inorder successor for the given key in a BSTMedium
  364. 364. Replace every array element with the least greater element on its rightMedium
  365. 365. Fix a binary tree that is only one swap away from becoming a BSTHard
  366. 366. Update every key in a BST to contain the sum of all greater keysMedium
  367. 367. Check if a given sequence represents the preorder traversal of a BSTHard
  368. 368. Build a Binary Search Tree from a postorder sequenceHard
  369. 369. Build a Binary Search Tree from a preorder sequenceHard
  370. 370. Count subtrees in a BST whose nodes lie within a given rangeMedium
  371. 371. Find the size of the largest BST in a binary treeHard
  372. 372. Calculate sum of root to leaf digits in a binary treeMedium
  373. 373. Count paths with the given sum in a binary treeHard
  374. 374. Print complete Binary Search Tree (BST) in increasing orderEasy
  375. 375. Print binary tree structure with its contentsMedium
  376. 376. Binary Search AlgorithmEasy
  377. 377. Find the number of rotations in a circularly sorted arrayEasy
  378. 378. Search an element in a circularly sorted arrayMedium
  379. 379. Find the first or last occurrence of a given number in a sorted arrayEasy
  380. 380. Count occurrences of a number in a sorted array with duplicatesMedium
  381. 381. Find the smallest missing element from a sorted arrayMedium
  382. 382. Find floor and ceil of a number in a sorted integer arrayEasy
  383. 383. Search in a nearly sorted array in logarithmic timeMedium
  384. 384. Find the number of 1’s in a sorted binary arrayEasy
  385. 385. Find the peak element in an arrayMedium
  386. 386. Maximum Subarray Sum using Divide and ConquerMedium
  387. 387. Efficiently implement power functionEasy
  388. 388. Find the missing term in a sequence in logarithmic timeMedium
  389. 389. Find floor and ceil of a number in a sorted array (Recursive solution)Easy
  390. 390. Find the frequency of each element in a sorted array containing duplicatesEasy
  391. 391. Find the square root of a number using a binary searchEasy
  392. 392. Division of two numbers using binary search algorithmMedium
  393. 393. Find the odd occurring element in an array in logarithmic timeMedium
  394. 394. Find pairs with difference k in an array | Constant Space SolutionMedium
  395. 395. Find k closest elements to a given value in an arrayMedium
  396. 396. Find the maximum value of j – i such that A[j] > A[i] in an arrayMedium
  397. 397. Longest Common Prefix (LCP) ProblemEasy
  398. 398. Binary Search in C++ STL and Java CollectionsBeginner
  399. 399. Ternary Search vs Binary searchBeginner
  400. 400. Exponential searchEasy
  401. 401. Unbounded Binary SearchEasy
  402. 402. Interpolation searchEasy
  403. 403. Introduction to Dynamic ProgrammingBeginner
  404. 404. Longest Common Subsequence ProblemMedium
  405. 405. Longest Common Subsequence (LCS) | Space optimized versionMedium
  406. 406. Longest Common Subsequence of k–sequencesMedium
  407. 407. Longest Common Subsequence | Finding all LCSHard
  408. 408. Longest Common Substring ProblemMedium
  409. 409. Longest Palindromic Subsequence using Dynamic ProgrammingMedium
  410. 410. Longest Repeated Subsequence ProblemMedium
  411. 411. Implement Diff UtilityMedium
  412. 412. Shortest Common Supersequence ProblemMedium
  413. 413. Shortest Common Supersequence | Finding all SCSHard
  414. 414. Shortest Common Supersequence Problem using LCSHard
  415. 415. Longest Increasing Subsequence using Dynamic ProgrammingHard
  416. 416. Longest Decreasing Subsequence ProblemHard
  417. 417. Longest Bitonic SubsequenceMedium
  418. 418. Maximum Sum Increasing Subsequence ProblemMedium
  419. 419. The Levenshtein distance (Edit distance) ProblemMedium
  420. 420. Find the size of the largest square submatrix of 1’s present in a binary matrixMedium
  421. 421. Matrix Chain Multiplication using Dynamic ProgrammingHard
  422. 422. Find minimum cost to reach the last cell of a matrix from its first cellMedium
  423. 423. Find the longest sequence formed by adjacent numbers in the matrixMedium
  424. 424. Count the number of paths in a matrix with a given cost to reach the destination cellMedium
  425. 425. 0–1 Knapsack ProblemMedium
  426. 426. Maximize the value of an expressionHard
  427. 427. Partition Problem using Dynamic ProgrammingMedium
  428. 428. Subset Sum Problem – Dynamic Programming SolutionMedium
  429. 429. 3–Partition ProblemMedium
  430. 430. Minimum Sum Partition ProblemHard
  431. 431. Rod Cutting ProblemMedium
  432. 432. Maximum Product Rod CuttingMedium
  433. 433. Coin change-making problemMedium
  434. 434. Coin Change ProblemHard
  435. 435. Total possible solutions to a linear equation of k variablesHard
  436. 436. Longest Alternating Subsequence ProblemMedium
  437. 437. Longest Alternating Subsequence Problem – IIMedium
  438. 438. Count the number of times a pattern appears in a given string as a subsequenceHard
  439. 439. Collect maximum points in a matrix by satisfying given constraintsHard
  440. 440. Find all n-digit binary numbers without any consecutive 1’sEasy
  441. 441. Count total possible combinations of n-digit numbers in a mobile keypadMedium
  442. 442. Word Break Problem – Dynamic ProgrammingHard
  443. 443. Determine the minimal adjustment cost of an arrayHard
  444. 444. Check if a string is k–palindrome or notHard
  445. 445. Find total ways to achieve a given sum with n throws of dice having k facesMedium
  446. 446. Wildcard Pattern MatchingHard
  447. 447. Find the number of ways to fill an N × 4 matrix with 1 × 4 tilesMedium
  448. 448. Ways to reach the bottom-right corner of a matrix with exactly k turns allowedHard
  449. 449. Weighted Interval Scheduling ProblemMedium
  450. 450. Box Stacking ProblemHard
  451. 451. Find total ways to reach n’th stair with at-most m stepsMedium
  452. 452. Find total ways to reach the n’th stair from the bottomMedium
  453. 453. Activity Selection Problem using Dynamic ProgrammingMedium
  454. 454. Find the minimum number of deletions required to convert a string into a palindromeMedium
  455. 455. Calculate the minimum cost to reach the destination city from the source cityMedium
  456. 456. Pots of Gold Game Problem using Dynamic ProgrammingHard
  457. 457. Find minimum cuts needed for the palindromic partition of a stringHard
  458. 458. Weighted Interval Scheduling – Dynamic Programming SolutionMedium
  459. 459. Find minimum jumps required to reach the destinationMedium
  460. 460. Find the probability that a person is alive after taking n steps on an islandMedium
  461. 461. Maximum Length Snake SequenceMedium
  462. 462. Calculate the size of the largest plus of 1’s in a binary matrixHard
  463. 463. Longest Increasing Subsequence using LCSMedium
  464. 464. Find maximum profit earned from at most k stock transactionsHard
  465. 465. Count all paths in a matrix from the first cell to the last cellEasy
  466. 466. Check if a string matches with the given wildcard patternHard
  467. 467. Check if a string is interleaving of two other given stringsMedium
  468. 468. Find all employees who directly or indirectly reports to a managerHard
  469. 469. Find optimal cost to construct a binary search treeHard
  470. 470. Find the maximum sum of a subsequence with no adjacent elementsMedium
  471. 471. Minimum-weight triangulation of a convex polygonHard
  472. 472. Find maximum profit that can be earned by conditionally selling stocksEasy
  473. 473. Program to find n’th Fibonacci numberEasy
  474. 474. Count decodings of a given sequence of digitsMedium
  475. 475. Hat Check Problem – Counting DerangementsMedium
  476. 476. Maximum Independent Set ProblemMedium
  477. 477. Find the minimum number of squares that sum to a given numberMedium
  478. 478. Truncate an integer array such that 2×min becomes more than maxHard
  479. 479. Longest Alternating Subarray ProblemEasy
  480. 480. Find maximum profit earned from at most two stock transactionsHard
  481. 481. Find ways to calculate a target from elements of the specified arrayMedium
  482. 482. Calculate the sum of all elements in a submatrix in constant timeMedium
  483. 483. Find maximum sum K × K submatrix in a given M × N matrixHard
  484. 484. Find maximum sum submatrix present in a matrixMedium
  485. 485. Find the length of the longest path in a matrix with consecutive charactersMedium
  486. 486. Collect maximum value of coins in a matrixHard
  487. 487. Terminology and Representations of GraphsBeginner
  488. 488. Graph Implementation – C, C++, C++ STL, Java Collections, PythonBeginner
  489. 489. Depth First Search (DFS)Medium
  490. 490. Breadth-First Search (BFS)Medium
  491. 491. Arrival and departure time of vertices in DFSEasy
  492. 492. Types of edges involved in DFS and relation between themBeginner
  493. 493. Determine whether a graph is Bipartite using DFSMedium
  494. 494. Topological Sort Algorithm for DAGMedium
  495. 495. Kahn’s Topological Sort AlgorithmMedium
  496. 496. Transitive closure of a graphEasy
  497. 497. Determine whether an undirected graph is a tree (Acyclic Connected Graph)Medium
  498. 498. 2–Edge Connectivity in a graphHard
  499. 499. 2–Vertex Connectivity in a graphHard
  500. 500. Check if a digraph is a DAG (Directed Acyclic Graph) or notMedium
  501. 501. Disjoint–Set Data Structure (Union–Find Algorithm)Medium
  502. 502. Check if a graph is strongly connected or notEasy
  503. 503. Check if a graph is strongly connected or not using one DFS TraversalHard
  504. 504. Union–Find Algorithm for cycle detection in a graphMedium
  505. 505. Single-Source Shortest Paths – Bellman–Ford AlgorithmMedium
  506. 506. All-Pairs Shortest Paths – Floyd Warshall AlgorithmEasy
  507. 507. Find the cost of the shortest path in DAG using one pass of Bellman–FordMedium
  508. 508. Determine a negative-weight cycle in a graphMedium
  509. 509. Find all Possible Topological Orderings of a DAGHard
  510. 510. Find correct order of alphabets in a given dictionary of ancient originHard
  511. 511. Find the longest path in a Directed Acyclic Graph (DAG)Hard
  512. 512. Print all k–colorable configurations of a graph (Vertex coloring of a graph)Medium
  513. 513. Print all Hamiltonian paths present in a graphHard
  514. 514. Graph Coloring ProblemMedium
  515. 515. Kruskal’s Algorithm for finding Minimum Spanning TreeHard
  516. 516. Eulerian cycle in directed graphsHard
  517. 517. Find root vertex of a graphMedium
  518. 518. Check whether an undirected graph is EulerianMedium
  519. 519. Check if a set of words can be rearranged to form a circleHard
  520. 520. Find itinerary from the given list of departure and arrival airportsEasy
  521. 521. Introduction to Priority Queues using Binary HeapsBeginner
  522. 522. Min Heap and Max Heap Implementation – C++, JavaBeginner
  523. 523. Check if an array represents a min-heap or notMedium
  524. 524. Convert max heap to min heap in linear timeEasy
  525. 525. Find k’th largest element in an arrayMedium
  526. 526. Sort a k-sorted arrayMedium
  527. 527. Merge M sorted lists of variable lengthHard
  528. 528. Find k’th smallest element in an arrayMedium
  529. 529. Find the smallest range with at least one element from each of the given listsHard
  530. 530. Merge M sorted lists each containing N elementsHard
  531. 531. Find first k non-repeating characters in a string in a single traversalMedium
  532. 532. Connect n ropes with minimal costEasy
  533. 533. Return k’th largest element in a streamMedium
  534. 534. Huffman Coding Compression AlgorithmHard
  535. 535. Replace each array element by its corresponding rankEasy
  536. 536. Single-Source Shortest Paths – Dijkstra’s AlgorithmMedium
  537. 537. Construct a Cartesian tree from an inorder traversalMedium
  538. 538. Treap Data StructureBeginner
  539. 539. Implementation of Treap Data Structure (Insert, Search, and Delete)Hard
  540. 540. Heap Sort AlgorithmMedium
  541. 541. Introsort Algorithm – Overview and C++ ImplementationHard
  542. 542. External Merge Sort AlgorithmHard
  543. 543. Introduction to Linked ListsBeginner
  544. 544. Linked List Implementation – C, C++, Java, PythonBeginner
  545. 545. Linked List – Insertion at TailBeginner
  546. 546. Static Linked ListBeginner
  547. 547. Clone a Linked ListEasy
  548. 548. Delete a linked listEasy
  549. 549. Pop operation in a linked listEasy
  550. 550. Insert a node to its correct sorted position in a sorted linked listEasy
  551. 551. Rearrange linked list in increasing order (Sort linked list)Medium
  552. 552. Split nodes of a linked list into the front and back halvesEasy
  553. 553. Remove duplicates from a sorted linked listEasy
  554. 554. Move the front node of a linked list in front of another listEasy
  555. 555. Move even nodes to the end of the linked list in reverse orderMedium
  556. 556. Split a linked list into two lists where each list contains alternating elements from itMedium
  557. 557. Construct a linked list by merging alternate nodes of two given listsEasy
  558. 558. Merge two sorted linked lists into oneMedium
  559. 559. Efficiently merge k sorted linked listsHard
  560. 560. Intersection of two sorted linked listsMedium
  561. 561. Reverse a linked List – Iterative SolutionMedium
  562. 562. Reverse a Linked List – Recursive SolutionHard
  563. 563. Reverse every group of k nodes in a linked listMedium
  564. 564. Find k’th node from the end of a linked listEasy
  565. 565. Merge alternate nodes of two linked lists into the first listMedium
  566. 566. Merge two sorted linked lists from their endMedium
  567. 567. Delete every N nodes in a linked list after skipping M nodesEasy
  568. 568. Rearrange linked list in a specific manner in linear timeMedium
  569. 569. Check if a linked list is palindrome or notMedium
  570. 570. Move the last node to the front of a linked listEasy
  571. 571. Rearrange linked list in a specific mannerEasy
  572. 572. Floyd’s Cycle Detection AlgorithmEasy
  573. 573. Find start node of the cycle in a linked listMedium
  574. 574. Sort linked list containing 0’s, 1’s, and 2’s in a single traversalMedium
  575. 575. Remove duplicates from a linked list in a single traversalEasy
  576. 576. Rearrange linked list so that it has alternating high and low valuesMedium
  577. 577. Rearrange a linked list by separating odd nodes from even onesMedium
  578. 578. Calculate height of a binary tree with leaf nodes forming a circular doubly linked listMedium
  579. 579. XOR Linked List – Overview and Implementation in C/C++Medium
  580. 580. Recursively check if the linked list of characters is palindrome or notMedium
  581. 581. Merge two BSTs into a doubly-linked list in sorted orderHard
  582. 582. Remove redundant nodes from a path formed by a linked listMedium
  583. 583. Add a single-digit number to a linked list representing a numberMedium
  584. 584. Reverse every alternate group of k nodes in a linked listMedium
  585. 585. Determine whether a linked list is palindrome or notMedium
  586. 586. Reverse a doubly linked listEasy
  587. 587. Pairwise swap adjacent nodes of a linked listMedium
  588. 588. Flatten a Linked ListHard
  589. 589. Check if a linked list of strings is palindromicEasy
  590. 590. Flatten a multilevel linked listMedium
  591. 591. Construct a height-balanced BST from an unbalanced BSTHard
  592. 592. Swap k’th node from beginning with k’th node from the end in a linked listMedium
  593. 593. Add two linked lists without using any extra spaceMedium
  594. 594. Remove all nodes from a linked list that matches a given keyEasy
  595. 595. Clone a linked list with random pointerHard
  596. 596. Update random pointer for each linked list node to point to the maximum nodeMedium
  597. 597. Link nodes present in each level of a binary tree in the form of a linked listHard
  598. 598. Convert a ternary tree to a doubly-linked listMedium
  599. 599. Construct a height-balanced BST from a sorted doubly linked listHard
  600. 600. In-place merge two sorted linked lists without modifying links of the first listMedium
  601. 601. Reverse specified portion of a linked listMedium
  602. 602. Find the intersection point of two linked listsMedium
  603. 603. Extract leaves of a binary tree into a doubly-linked listMedium
  604. 604. Find the vertical sum of a binary treeHard
  605. 605. In-place convert a binary tree to a doubly-linked listHard
  606. 606. Find a triplet with the given sum in a BSTHard
  607. 607. Check whether the leaf traversal of given binary trees is the same or notHard
  608. 608. Merge sort algorithm for a singly linked listHard
  609. 609. Sort a doubly-linked list using merge sortMedium
  610. 610. Stack Implementation using a Linked ListBeginner
  611. 611. Clock Angle ProblemEasy
  612. 612. Add two numbers without using the addition operator | 5 methodsEasy
  613. 613. Generate the power set of a given setMedium
  614. 614. Implement power function without using multiplication and division operatorsEasy
  615. 615. Print all numbers between 1 to N without using a semicolonMedium
  616. 616. Swap two numbers without using a third variable | 5 methodsEasy
  617. 617. Determine the if condition to print the specific outputEasy
  618. 618. Find maximum and minimum value of a triplet without using a conditional statementMedium
  619. 619. Find numbers represented as the sum of two cubes for two different pairsMedium
  620. 620. Print “Hello World” with empty main function | 3 methodsMedium
  621. 621. Tower of Hanoi ProblemMedium
  622. 622. Print all numbers between 1 to N without using any loop | 4 methodsEasy
  623. 623. Print a semicolon without using a semicolon anywhere in the programEasy
  624. 624. Multiply two numbers without using a multiplication operator or loopsEasy
  625. 625. Find the square of a number without using the multiplication and division operatorEasy
  626. 626. Check if a number is even or odd without using any conditional statementEasy
  627. 627. Set both elements of a binary array to 0 in a single lineEasy
  628. 628. Find minimum number without using conditional statement or ternary operatorMedium
  629. 629. Perform division of two numbers without using division operatorMedium
  630. 630. Generate 0 and 1 with 75% and 25% probabilityMedium
  631. 631. Generate desired random numbers with equal probabilityMedium
  632. 632. Return 0, 1, and 2 with equal probability using a specified functionMedium
  633. 633. Generate numbers from 1 to 7 with equal probability using a specified functionHard
  634. 634. Get 0 and 1 with equal probability using a specified functionMedium
  635. 635. Generate random input from an array according to given probabilitiesMedium
  636. 636. Generate fair results from a biased coinHard
  637. 637. Implement ternary operator without using conditional expressionsMedium
  638. 638. Determine if two integers are equal without using comparison and arithmetic operatorsEasy
  639. 639. Compute modulus division without division and modulo operatorEasy
  640. 640. Write a C/C++ program without using the main functionEasy
  641. 641. Single line expressions to swap two integers in JavaEasy
  642. 642. Find maximum number without using conditional statement or ternary operatorEasy
  643. 643. Find minimum or maximum of two integers without using branchingHard
  644. 644. Solve a given set of problems without using multiplication or division operatorsMedium
  645. 645. Queue implementation using an array – C, C++, C++ (Using Templates), Java, PythonBeginner
  646. 646. Queue Implementation using a Linked ListBeginner
  647. 647. Implement a stack using the queue data structureMedium
  648. 648. Implement a queue using the stack data structureMedium
  649. 649. Efficiently print all nodes between two given levels in a binary treeEasy
  650. 650. Chess Knight Problem | Find the shortest path from source to destinationHard
  651. 651. Shortest path in a maze – Lee AlgorithmMedium
  652. 652. Find the shortest safe route in a field with sensors presentHard
  653. 653. Flood Fill AlgorithmMedium
  654. 654. Count number of islandsMedium
  655. 655. Find shortest path from source to destination in a matrix that satisfies given constraintsHard
  656. 656. Generate binary numbers between 1 to n using a queueEasy
  657. 657. Print nodes of a binary tree in vertical orderMedium
  658. 658. Print all nodes of a perfect binary tree in a specific orderHard
  659. 659. Print left view of a binary treeEasy
  660. 660. Find the next node at the same level as the given node in a binary treeMedium
  661. 661. Check if a binary tree is a complete binary tree or notMedium
  662. 662. Print diagonal traversal of a binary treeMedium
  663. 663. Print corner nodes of every level in a binary treeEasy
  664. 664. Invert Binary TreeEasy
  665. 665. Find minimum passes required to convert all negative values in a matrixHard
  666. 666. Convert a binary tree into a doubly-linked list in spiral orderHard
  667. 667. Check if a binary tree is a min-heap or notMedium
  668. 668. Invert alternate levels of a perfect binary treeHard
  669. 669. Convert a Binary Search Tree into a Min HeapHard
  670. 670. Snake and Ladder ProblemHard
  671. 671. Find the shortest distance of every cell from a landmine inside a mazeHard
  672. 672. Convert a multilevel linked list to a singly linked listMedium
  673. 673. Check if an undirected graph contains a cycle or notMedium
  674. 674. Find maximum cost path in a graph from a given source to a given destinationMedium
  675. 675. Total paths in a digraph from a given source to a destination having exactly m edgesMedium
  676. 676. Least cost path in a digraph from a given source to a destination having m edgesMedium
  677. 677. Traverse a given directory using BFS and DFS in JavaEasy
  678. 678. Perform vertical traversal of a binary treeMedium
  679. 679. Compute the maximum number of nodes at any level in a binary treeEasy
  680. 680. Print right view of a binary treeMedium
  681. 681. Find the minimum depth of a binary treeEasy
  682. 682. Depth-First Search (DFS) vs Breadth-First Search (BFS)Beginner
  683. 683. Bipartite GraphMedium
  684. 684. Compute the least cost path in a weighted digraph using BFSMedium
  685. 685. Find the path between given vertices in a directed graphEasy
  686. 686. Construct a directed graph from an undirected graph that satisfies given constraintsMedium
  687. 687. Trie Implementation – C, C++, C++ (Memory Efficient), Java, PythonBeginner
  688. 688. Longest Common Prefix in a given set of strings (using Trie)Medium
  689. 689. Lexicographic sorting of a given set of keysMedium
  690. 690. Lexicographic rank of a stringHard
  691. 691. Find the maximum occurring word in a given set of stringsEasy
  692. 692. Find first k maximum occurring words in a given set of stringsMedium
  693. 693. Find duplicate rows in a binary matrixMedium
  694. 694. Word Break Problem – Using Trie Data StructureMedium
  695. 695. Generate a list of possible words from a character matrixHard
  696. 696. Find all words matching a pattern in the given dictionaryMedium
  697. 697. Find the shortest unique prefix for every word in an arrayMedium
  698. 698. Remove loop from a linked listMedium
  699. 699. Find number of customers who could not get any computerEasy
  700. 700. Find the smallest missing positive number from an unsorted arrayMedium
  701. 701. Print all pairs of anagrams in a set of stringsMedium
  702. 702. Find total arrangements such that no two balls of the same color are togetherHard
  703. 703. Determine whether a BST is skewed from its preorder traversalEasy
  704. 704. Determine whether two nodes lie on the same path in a binary treeMedium
  705. 705. Find height of a binary tree represented by the parent arrayMedium
  706. 706. In-place merge two height-balanced BSTsHard
  707. 707. Check if removing an edge can split a binary tree into two equal size treesEasy
  708. 708. Find read-write conflicts among given database transactionsMedium
  709. 709. Construct a complete binary tree from its linked list representationEasy
  710. 710. Find the minimum number of merge operations to make an array palindromeMedium
  711. 711. Check whether a directed graph is EulerianMedium
  712. 712. Count nodes in a BST that lies within a given rangeEasy
  713. 713. Check if a number is a power of 8 or notMedium
  714. 714. Check if a number is a perfect squareEasy
  715. 715. Shrink an array by removing triplets that satisfy given constraintsHard
  716. 716. Count distinct permutations of an array that sums to a targetMedium
  717. 717. Check if a string can be constructed from another stringEasy
  718. 718. Check children-sum property in a binary treeEasy

Rate this post

Average rating 4.88/5. Vote count: 5956

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Tell us how we can improve this post?

Thanks for reading.

To share your code in the comments, please use our online compiler that supports C, C++, Java, Python, JavaScript, C#, PHP, and many more popular programming languages.

Like us? Refer us to your friends and support our growth. Happy coding :)


guest
104 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Do NOT follow this link or you will be banned from the site!