Algorithm Problems

Collection of Hundreds of Data Structures and Algorithms Problems and Solutions

Collection of hundreds of Data Structure and Algorithms Problems and solutions from different sources, including leetcode.com, hackerrank.com, pramp, Cracking The Coding Interview, Glassdoor, and real-world interviews from top-tier tech companies including Amazon, Facebook, Google, LinkedIn, Twitter, Microsoft.
  1. The question descriptions, the solutions, and their implementation are as follows:
    1. 2 Sum Problem
    2. 2 Sum Problem II - find all pairs with the difference of K.
    3. 3 Sum Problem
    4. 3 Sum Closest
    5. 4 Sum Problem
    6. Activity Selection Profit
    7. Add Binary
    8. Add Digits
    9. Add Strings
    10. Add Two Numbers
    11. Additive Numbers
    12. Adjacent Character Remove
    13. Anagram Closer
    14. Anagram Consecutive
    15. Animal Queue
    16. Arithmetic Slices
    17. Array 3 Sum with Multiplicity
    18. Array Contiguous Sub Array With Sum K Count
    19. Array Difference
    20. Array Division to Three Stacks
    21. Array Duplicate
    22. Array Duplicate II
    23. Array Duplicate III
    24. Array Duplicate Number
    25. Array Equillibrium Pivot Index
    26. Array Equillibrium Point
    27. Array Even Odd Sorting
    28. Array Find Minimum In Rotated Sorted Array 
    29. Array First and Last Position 
    30. Array GCD Finding 
    31. Array Get Different Number
    32. Array Increasing Triplet Sequence
    33. Array Index Element Equality 
    34. Array Intersection
    35. Array K Difference Pairs 
    36. Array Kth Largest Element
    37. Array Largest Number Combination 
    38. Array Max Increasing Index 
    39. Array Max Product Three Numbers
    40. Array Maximum Product SubArray 
    41. Array Maximum Sum SubArray
    42. Array Missing Number 
    43. Array Product of Array Except Self
    44. Array Parity Ordering
    45. Array Partition I 
    46. Array Peak Element
    47. Array Product Except Self 
    48. Array Product SubArray Less than K
    49. Array Remove Alternate Duplicate Characters 
    50. Array Search in Rotated Sorted Array  
    51. Array Search in Rotated Sorted Array II
    52. Array Search Unknown Size
    53. Array Shortest Unsorted SubArray 
    54. Array Single Duplicate  
    55. Array Stream Kth Largest
    56. Array Subset Partition Almost Equal Sum
    57. Array Subset Partition Equal Sum 
    58. Array Subset Sum
    59. Array Subsets 
    60. Array Subsets Duplicate Elements
    61. Array Three Keys Sorting
    62. Array Top K Frequent Elements 
    63. Array Two Missing Numbers
    64. Array With Single Entry  
    65. Assign Cookies
    66. Balanced Binary Tree
    67. Base Conversion
    68. Best Time To Buy and Sell Stock
    69. Best Time to Buy and Sell Stock II
    70. Best Time to Buy and Sell Stock III
    71. Best Time to Buy and Sell Stock IV
    72. Best Time to Buy and Sell Stock with Cooldown
    73. Best Time to Buy and Sell Stock with Transfer Fee
    74. BFS Tree Traversal (Breadth First Search Tree Traversal)
    75. Binary Tree Check if Binary Search Tree
    76. Binary Search
    77. Binary Search Tree from Sorted Array
    78. Binary Search Tree Iterator
    79. Binary Search Tree Kth Smallest Element
    80. Binary Search Tree Inorder Successor
    81. Binary Tree Common Ancestor
    82. Binary Tree Extract Leaf Nodes to Doubly Linked List
    83. Binary Tree From Preorder and Inorder String
    84. Binary Tree Inorder Traversal
    85. Binary Tree K Nodes Apart
    86. Binary Tree Level Order Traversal
    87. Binary Tree Level Order Traversal II
    88. Binary Tree Linked List Level
    89. Binary Tree Maximum Depth
    90. Binary Tree Paths
    91. Binary Tree Path Sum Root Node
    92. Binary Tree Path Sum Starting and Ending AnyWhere
    93. Binary Tree Postorder Traversal
    94. Binary Tree Preorder Traversal
    95. Binary Tree Root to Leaf Path Sum Check
    96. Binary Tree Root to Leaf Sum All Paths
    97. Binary Tree Right side view
    98. Binary Tree Subtree check (Subtree of another tree)
    99. Binary Tree Zigzag Traversal
    100. Bitwise AND of Numbers range
    101. Bulb Switcher
    102. Bulls and Cows
    103. Climbing Stairs
    104. Clone Graph
    105. Coin Change *
    106. Coin Change II *
    107. Combination Sum
    108. Combination Sum II
    109. Combination Sum III
    110. Combinations
    111. Compare Version Numbers
    112. Construct Binary Tree from Inorder and Preorder Traversal
    113. Construct Binary Tree from Preorder and Inorder Traversal
    114. Container With Most Water
    115. Contains Duplicate
    116. Contains Duplicate II
    117. Contains Duplicate III *
    118. Convert Sorted Array To Binary Search Tree *
    119. Convert Sorted List To Binary Search Tree *
    120. Count and Say
    121. Count complete tree nodes *
    122. Count Primes
    123. Course Schedule *
    124. Course Schedule II *
    125. Different ways to add parenthesis
    126. Edit Distance **
    127. Divide Two Integers
    128. Evaluate Reverse Polish Notation
    129. Excel Sheet Column Number and Title
    130. Find item in Rotated Sorted Array
    131. Find item in Rotated Sorted Array II
    132. Find Minimum in Rotated Sorted Array *
    133. Find Minimum in Rotated Sorted Array II **
    134. Find Peak Element *
    135. First Missing Positive
    136. First Bad Version
    137. Flatten Binary Tree to Linked List *
    138. Fraction to Recurring Decimal *
    139. Gas Station *
    140. Gray Code *
    141. Group Anagrams *
    142. H-Index *
    143. H-Index II *
    144. Happy Number
    145. House Robber
    146. House Robber II
    147. House Robber III
    148. Generate Parenthesis
    149. Implement Queue using Stack
    150. Implement Stack using Queue
    151. Implement Queue using Stack
    152. Implement Trie (Prefix Tree) *
    153. Insertion sort List *
    154. Integer to English words *
    155. Integer to Roman
    156. Intersection of Two Linked Lists
    157. Invert Binary Tree
    158. Isomorphic Strings
    159. Jump Game *
    160. Jump Game II **
    161. Letter combination of a Phone Number
    162. Linked List Delete Node
    163. Longest Common Prefix
    164. Longest Palindromic Substring
    165. Median of Two Sorted Arrays
    166. Merge Two Sorted Lists
    167. Palindrome Number
    168. Pow(x,n)
    169. Remove Duplicates from Sorted Array
    170. Remove Element
    171. Reverse Integer
    172. Roman to Integer
    173. Search for a Range
    174. Search Insert Position
    175. Valid Parentheses
    176. ZigZag Conversion