Data Structures and Algorithms Practice Problems

  1. Two Sum
  2. Zero Sum
  3. Zero Sum II
  4. Sort Binary Array
  5. Maximum Length Subarray
  6. Largest Subarray
  7. Maximum Product Pair
  8. Dutch National Flag Problem
  9. Merge Arrays
  10. Merge Arrays II
  11. Maximum Continuous Sequence
  12. Maximum Continuous Sequence II
  13. Equilibrium Index
  14. Largest Consecutive Subarray
  15. Majority Element
  16. Move Zeroes to End
  17. Replace Array Elements
  18. Replace Array Elements II
  19. Longest Bitonic Subarray
  20. Maximum Difference Pair
  21. Maximum Sum Subarray
  22. Maximum Sum Subarray II
  23. Maximum Sum Circular Subarray
  24. Rearrange Array
  25. Rearrange Array II
  26. Rearrange Array III
  27. Rearrange Array IV
  28. Rearrange Array V
  29. Sorted Merge Arrays
  30. Sorted Merge Arrays II
  31. Combinations
  32. Combinations II
  33. Combinations III
  34. Combinations IV
  35. Combinations V
  36. Combinations VI
  37. Combinations VII
  38. Combinations VIII
  39. Combinations IX
  40. Combinations X
  41. Combinations XI
  42. Subset Sum
  43. Ball Arrangements
  44. Minimum Sum Subarray
  45. Maximum Product Subarray
  46. K Sum Subarray
  47. K Sum Subarray II
  48. Smallest Subarray
  49. Smallest Window to Sort Array
  50. Maximum Path Sum
  51. Buy N Sell Shares
  52. Trapping Rain Water
  53. Minimum Platforms
  54. Decode Array
  55. Sort Array Single Swap
  56. 3 Sum
  57. 3 Sum II
  58. 3 Sum III
  59. Longest Continuous Sequence
  60. Reverse Consecutive Elements
  61. Maximum Product Subset
  62. 2 Diff
  63. 4 Sum
  64. Arithmetic Triplets
  65. Geometric Triplets
  66. Buy and Sell Stock
  67. Buy and Sell Stock II
  68. Buy and Sell Stock III
  69. Group Elements
  70. Minimum Absolute Difference
  71. Minimum Absolute Difference II
  72. Symmetric Pairs
  73. Closest Pair
  74. Partition Array Equal Sum
  75. Distinct Elements Count
  76. Maximum Sum Number
  77. Largest Distinct Subarrays
  78. Maximum Product Triplet
  79. Repeating Element Index
  80. Minimum Absolute Sum Pair
  81. Consecutive Numbers
  82. Non Overlapping Pairs
  83. Add Arrays
  84. Minimum Product Triplet
  85. Distinct Absolute Count
  86. Break Point Index
  87. Frequency Map
  88. Frequency Map II
  89. Sorted Triplet
  90. Shuffle Array
  91. Shuffle Array II
  92. Shuffle Array III
  93. Strictly Increasing Subarrays
  94. Duplicates in Range K
  95. Minimum Range
  96. Minimum Range II
  97. Longest Consecutive Subsequence
  98. Determine Index
  99. Minimum Moves to Convert Array
  100. Left Rotate Array
  101. Right Rotate Array
  102. Activity Selection Problem
  103. K Divisible Pairs
  104. Minimum Removals
  105. Two Sum II
  106. Greater Elements
  107. Sort Array
  108. Counting Sort
  109. Inversion Count
  110. Inversion Count II
  111. Sort by Frequency and Index
  112. Sort with Duplicates
  113. Largest Number
  114. Surpasser Count
  115. 3 Partition Problem
  116. 3 Partition Problem II
  117. K Partition Problem
  118. Minimum Merge Operations
  119. Coin Change Problem
  120. Coin Change Problem II
  121. Power Set
  122. Power Set II
  123. Missing Number
  124. Missing Number II
  125. Missing Number III
  126. Odd Occurring Element
  127. Odd Occurring Element II
  128. Odd Occurring Element III
  129. Odd Occurring Element IV
  130. Duplicate Element
  131. Duplicate Element II
  132. Missing and Duplicate Element
  133. Next Greater Element
  134. Next Greater Element II
  135. Previous Smaller Element
  136. Longest Increasing Subsequence
  137. Longest Increasing Subsequence II
  138. Merging Overlapping Intervals
  139. Maximum Overlapping Intervals
  140. Unattended Customers Count
  141. Minimum Number K Swaps
  142. Rod Cutting
  143. Rod Cutting II
  144. Shrink Array
  145. Ticket Itinerary
  146. Sort K Sorted Array
  147. Job Sequencing Problem
  148. Employees Manager Mapping
  149. Snake and Ladder Problem
  150. Spiral Matrix
  151. Spiral Matrix II
  152. Spiral Matrix III
  153. Shift Matrix
  154. Convert Matrix
  155. Convert Matrix II
  156. Diagonal Matrix Traversal
  157. Replace Matrix
  158. Replace Matrix II
  159. Rotate Matrix
  160. Rotate Matrix II
  161. Negative Numbers Count
  162. Search Matrix
  163. Search Matrix II
  164. Toeplitz Matrix
  165. Fill Matrix
  166. Common Elements
  167. Maximum Ones Row
  168. Largest Square Submatrix
  169. Largest Square Submatrix II
  170. Largest Rectangle Area
  171. Maximum Difference Pair II
  172. N Queen Problem
  173. Knight Tour Problem
  174. Chess Knight Problem
  175. Shortest Path
  176. Shortest Path II
  177. Shortest Path III
  178. Longest Path
  179. Matrix Path
  180. Matrix Path II
  181. Matrix Path III
  182. Matrix Path IV
  183. Matrix Path V
  184. Matrix Path VI
  185. Matrix Path VII
  186. Minimum Cost Path
  187. Minimum Cost Path II
  188. Longest Continuous Sequence II
  189. Longest Continuous Sequence III
  190. Collect Maximum Points
  191. Tiles Problem
  192. Largest Plus
  193. Collect Coins
  194. Duplicate Rows
  195. Boggle Search
  196. Submatrix Sum
  197. Maximum Sum Submatrix
  198. Maximum Sum Submatrix II
  199. Alive Probability
  200. Maximum Length Snake Sequence
  201. Flood Fill Algorithm
  202. Count Islands
  203. Construct Young Tableau
  204. Extract Min in Young Tableau
  205. Replace Element in Young Tableau
  206. Sort with Young Tableau
  207. Magnet Puzzle
  208. Rotated Palindrome
  209. Longest Palindromic Substring
  210. Repeated Subsequence
  211. Derive Strings
  212. Check Circular Moves
  213. Excel Sheet Column Name
  214. Check Anagram
  215. Interleaving String
  216. Interleaving String II
  217. Isomorphic Strings
  218. Palindromic Substrings
  219. Group Anagrams
  220. Transform String
  221. Transform String II
  222. Transform String III
  223. Balanced Expression
  224. Longest Palidromic Sum Substring
  225. Print String Zig Zag
  226. Run Length Encoding
  227. Longest Distinct Substring
  228. Longest Distinct Substring II
  229. Palindromic Permutations
  230. Anagram Substring
  231. Maximum Occurring Word
  232. Permutations
  233. Permutations II
  234. Next Permutations
  235. Lexical Minimal String Rotation
  236. Balanced Parentheses
  237. Duplicate Parenthesis
  238. Evaluate Postfix Expression
  239. Infix to Postfix
  240. Palindrome String
  241. Minimum Inversions
  242. Remove Adjacent Duplicates
  243. Remove Adjacent Duplicates II
  244. First Non Repeating Character
  245. Lexicographic Permutations
  246. Lexicographic Rank
  247. Decode Sequence
  248. K Distinct Substrings
  249. Pattern Match
  250. Pattern Match II
  251. Pattern Match III
  252. Pattern Match IV
  253. Pattern Match V
  254. Wildcard Pattern Matching
  255. Wildcard Pattern Matching II
  256. Longest Balanced Parenthesis
  257. Longest Palindrome
  258. Reverse Text
  259. N Digit Numbers
  260. N Digit Numbers II
  261. N Digit Numbers III
  262. N Digit Numbers IV
  263. N Digit Numbers V
  264. N Digit Numbers VI
  265. N Digit Numbers VII
  266. First K Non Repeating
  267. K Palindrome String
  268. Minimum Delete Operations
  269. Minimum Cut Palindromic Partition
  270. Lexicographic Sorting
  271. Shortest Unique Prefix
  272. Rearrange Words
  273. Turn off Kth Bit
  274. Turn on Kth Bit
  275. Is Kth Bit Set
  276. Toggle Kth Bit
  277. Unset Rightmost Set Bit
  278. Position of Rightmost Set Bit
  279. Count Set Bits
  280. Count Flipped Bits
  281. Next Power of 2
  282. Previous Power of 2
  283. Parity of Number
  284. Swap Bits
  285. Swap Bits II
  286. Power of 4
  287. Power of 8
  288. Reverse Bits
  289. Swap Adjacent Bits
  290. Adjacent Set Bits
  291. Decimal to Binary
  292. Add Binary
  293. Circular Shift
  294. XOR Without XORing
  295. Search Sorted Array
  296. Unbounded Search Sorted Array
  297. Rotation Count
  298. Search Circular Array
  299. First and Last Occurrence
  300. Count Occurrences
  301. Smallest Missing Number
  302. Smallest Missing Number II
  303. Floor and Ceil
  304. Search Nearly Sorted Array
  305. Count Ones
  306. Peak Element
  307. K Closest Elements
  308. Longest Common Prefix
  309. Implement Power Function
  310. Implement Square Root
  311. Check Min Heap
  312. Max Heap to Min Heap
  313. Kth Smallest Element
  314. Kth Largest Element
  315. Kth Largest Element II
  316. Merge Sorted Lists
  317. Connect N Ropes
  318. Replace Elements with Rank
  319. Longest Common Subsequence
  320. Longest Common Subsequence II
  321. Longest Common Subsequence III
  322. Longest Common Substring
  323. Longest Palindromic Subsequence
  324. Longest Repeated Subsequence
  325. Shortest Common Supersequence
  326. Shortest Common Supersequence II
  327. Longest Decreasing Subsequence
  328. Longest Bitonic Subsequence
  329. Max Sum Increasing Subsequence
  330. Edit Distance Problem
  331. Maximize Value
  332. 0/1 Knapsack Problem
  333. Partition Problem
  334. Subset Sum Problem
  335. Minimum Sum Partition Problem
  336. Longest Alternating Subsequence
  337. Linear Equation K Variables
  338. Word Break Problem
  339. Weighted Interval Scheduling
  340. Matrix Chain Multiplication
  341. Climbing Stairs
  342. Climbing Stairs II
  343. Pots of Gold Game
  344. Minimum Jumps
  345. Optimal Cost to Construct BST
  346. Maximum Sum Subsequence
  347. Nth Fibonacci Number
  348. Count Decodings
  349. Hat Check Problem
  350. Minimum Squares
  351. Truncate Array
  352. Dice Throw
  353. Minimum Weight Triangulation
  354. Longest Alternating Subarray
  355. Construct Linked List
  356. Construct Linked List II
  357. Pop Linked List Head
  358. Sorted Insert in Linked List
  359. Kth Node from End
  360. Delete Nodes Linked List
  361. Remove Redundant Nodes
  362. Add Number to Linked List
  363. Add Two Linked Lists
  364. Sort Linked List
  365. Dutch National Flag Problem II
  366. Sort Doubly Linked List
  367. Swap Nodes Linked List
  368. Swap Nodes Linked List II
  369. Detect Cycle Linked List
  370. Remove Cycle Linked List
  371. Split Linked List
  372. Split Linked List II
  373. Remove Duplicates Linked List
  374. Remove Duplicates Linked List II
  375. Clone Linked List
  376. Clone Linked List II
  377. Move Node Linked List
  378. Move Node Linked List II
  379. Sorted Intersect
  380. Shuffle Merge
  381. Shuffle Merge II
  382. Reverse Linked List
  383. Reverse Linked List II
  384. Reverse Linked List III
  385. Reverse Linked List IV
  386. Reverse Doubly Linked List
  387. Rearrange Linked List
  388. Rearrange Linked List II
  389. Rearrange Linked List III
  390. Rearrange Linked List IV
  391. Sorted Merge
  392. Sorted Merge II
  393. Sorted Merge III
  394. Sorted Merge IV
  395. Palindrome Linked List
  396. Palindrome Linked List II
  397. Update Random Pointer
  398. Lists Intersection Point
  399. Inorder Tree Traversal
  400. Preorder Tree Traversal
  401. Postorder Tree Traversal
  402. Level Order Traversal
  403. Spiral Order Traversal
  404. Reverse Level Order Traversal
  405. Check Identical Binary Trees
  406. Height of Binary Tree
  407. Height of Binary Tree II
  408. Height of Binary Tree III
  409. Clone Binary Tree
  410. Clone Binary Tree II
  411. Is Ancestor or Descendant
  412. Bottom View Binary Tree
  413. Top View Binary Tree
  414. Left View Binary Tree
  415. Right View Binary Tree
  416. Perfect Binary Tree Traversal
  417. Perfect Binary Tree Traversal II
  418. Boundary Traversal Binary Tree
  419. Diagonal Traversal Binary Tree
  420. Vertical Traversal Binary Tree
  421. Maximum Width Binary Tree
  422. Minimum Depth Binary Tree
  423. Corner Nodes in Each Level
  424. Cousin Nodes
  425. Cousin Nodes II
  426. Lowest Common Ancestor
  427. Ancestors of Binary Tree Node
  428. Height Balanced Binary Tree
  429. Height Balanced Binary Tree II
  430. Nodes Between Two Levels
  431. Distance Between Two Nodes
  432. K Distance Nodes from Leaves
  433. Transform Binary Tree
  434. Transform Binary Tree II
  435. Truncate Binary Tree
  436. Truncate Binary Tree II
  437. Sum Tree
  438. Root to Leaf Paths in Binary Tree
  439. Leaf to Root Paths in Binary Tree
  440. Mirror of Binary Tree
  441. Node Descendant Difference
  442. Alternate Levels Sum Difference
  443. Maximum Sum Path Binary Tree
  444. Maximum Sum Path Binary Tree II
  445. Maximum Sum Path Binary Tree III
  446. Construct Binary Tree
  447. Construct Binary Tree II
  448. Construct Binary Tree III
  449. Construct Binary Tree IV
  450. Construct Binary Tree V
  451. Construct Binary Tree VI
  452. Construct Cartesian Tree
  453. Construct LCRS Binary Tree
  454. Construct Expression Tree
  455. Evaluate Expression Tree
  456. Is Symmetric Binary Tree
  457. Is Complete Binary Tree
  458. Is Skewed Binary Tree
  459. Is Subtree
  460. Is Binary Tree Min Heap
  461. Diameter of Binary Tree
  462. Diagonal Sum Binary Tree
  463. Postorder from Inorder and Preorder
  464. Preorder from Inorder and Postorder
  465. Binary Trees with Same Inorder
  466. Maximum Independent Set Problem
  467. Next Node at Same Level
  468. Invert Alternate Levels
  469. Subtrees with Same Node Value
  470. Split Binary Tree
  471. Set Inorder Successor
  472. Vertical Sum Binary Tree
  473. Leaf Traversal Binary Tree
  474. Link Nodes Binary Tree
  475. Ternary Tree to Doubly Linked List
  476. Extract Binary Tree Leaves
  477. Binary Tree to Doubly Linked List
  478. Binary Tree to Doubly Linked List II
  479. Linked List to Complete Binary Tree
  480. Ancestor Matrix
  481. Construct BST
  482. Insert key into BST
  483. Search key in BST
  484. Delete key from BST
  485. Is Same BSTs
  486. Inorder Predecessor BST
  487. Inorder Successor BST
  488. Lowest Common Ancestor II
  489. Kth Smallest Node BST
  490. Kth Largest Node BST
  491. Floor and Ceil II
  492. 2 Sum BST
  493. 2 Sum BST II
  494. 3 Sum BST
  495. Transform BST
  496. Truncate BST
  497. Is Preorder Sequence of BST
  498. Is Skewed BST
  499. Nodes Within a Range in BST
  500. Subtrees Within a Range in BST
  501. Construct BST from Preorder
  502. Construct BST from Postorder
  503. Complete BST Traversal
  504. Merge BSTs to Doubly Linked List
  505. Merge Height Balanced BSTs
  506. Construct Height Balanced BST
  507. Construct Height Balanced BST II
  508. Construct Height Balanced BST III
  509. Convert Binary Tree to BST
  510. Largest BST Size
  511. Is BST
  512. Fix Binary Tree
  513. Probability
  514. Probability II
  515. Probability III
  516. Probability IV
  517. Probability V
  518. Probability VI
  519. Probability VII
  520. Probability VIII
  521. Is Bipartite Graph
  522. Is Connected Graph
  523. Is Acyclic Connected Graph
  524. Is DAG
  525. Topological Sort
  526. Root Vertex in Graph
  527. Connectivity Matrix
  528. Bridges in Graph
  529. K Colorable Graph
  530. Graph Coloring
  531. Is Strongly Connected Graph
  532. Detect Cycle in Graph
  533. Least Cost Path
  534. Least Cost Path II
  535. Least Cost Path III
  536. Greatest Cost Path
  537. Is Reachable Vertex
  538. Total Paths in Digraph
  539. Single Source Shortest Paths
  540. Single Source Shortest Paths II
  541. All Pairs Shortest Paths
  542. Minimum Spanning Tree
  543. Maximum Cost Path
  544. Negative Weight Cycle
  545. Hamiltonian Path
  546. Eulerian Path
  547. Eulerian Path II
  548. Eulerian Cycle
  549. Factorial
  550. Factorial Series
  551. Palindrome Number
  552. Primes in Range
  553. Minimum and Maximum Element
  554. Reverse Array
  555. Greatest Common Divisor
  556. Bezout Coefficients
  557. Cubes Sum
  558. Clock Angle Problem
  559. Tower of Hanoi Problem
  560. Sort Stack
  561. Reverse Stack
  562. Generate Binary Numbers
  563. Convert Number to Words
  564. Implement Strstr Function
  565. Shortest Superstring Problem