LeetCode Problem Companion


File name Concept Closest LeetCode Problem Description
2-1fibonacci Fibonacci sequence 509. Fibonacci Number Compute the n-th Fibonacci number efficiently.
2-3gcd Greatest Common Divisor 1979. Find Greatest Common Divisor of Array Find the GCD of numbers using the Euclidean algorithm.
2-4lcm Least Common Multiple 2413. Smallest Even Multiple — simplified LCM case Compute LCM (e.g., of n and 2) via a*b//gcd(a,b).
2-4lcm (advanced variant) Replace adjacent non-coprime numbers with their LCM 2197. Replace Non-Coprime Numbers in Array Uses LCM repeatedly to merge numbers into coprime sequence.
3-1change Minimum coins to make change 322. Coin Change Compute the minimum number of coins needed to make a target sum.
3-2fractional_knapsack Fractional knapsack (greedy) 1710. Maximum Units on a Truck Sort by value density and take as much as fits — same greedy pattern.
3-4covering_segments Minimum points to cover intervals 452. Minimum Number of Arrows to Burst Balloons Select minimum points to cover all segments (interval greedy).
3-6largest_number Arrange numbers to form the largest integer 179. Largest Number Sort strings by custom comparator to form the maximum concatenated number.
4-1binary_search Binary search 704. Binary Search Classic binary search in a sorted array.
4-2majority_element Majority element (> n/2 occurrences) 169. Majority Element Find element appearing more than ⌊n/2⌋ times using Boyer–Moore algorithm.
4-4inversions Count inversions using merge sort 493. Reverse Pairs Similar divide-and-conquer pattern for counting pair inversions.
4-5points_and_segments Count how many segments cover each point 436. Find Right Interval or 850. Rectangle Area II (conceptually related to interval sweep-line problems) Uses sweep line / sorting technique to track interval coverage.
4-6closest Closest pair of points in plane 973. K Closest Points to Origin (conceptually related) Find minimal Euclidean distance between two points (divide and conquer).
5-1change_dp Minimum coins to make change (DP) 322. Coin Change Classic DP problem: compute minimum coins to reach target amount.
5-3edit_distance Edit (Levenshtein) distance 72. Edit Distance Compute min operations (insert, delete, replace) to convert string A → B.
5-4lcs2 Longest Common Subsequence (2 strings) 1143. Longest Common Subsequence Standard DP to find LCS length between two strings.
6-1knapsack 0/1 Knapsack problem 416. Partition Equal Subset Sum or 494. Target Sum Both are DP problems built on the 0/1 knapsack principle (subset-sum DP).
6-2partition3 Partition array into 3 equal-sum subsets 698. Partition to K Equal Sum Subsets Generalized k-partition problem using backtracking/DP.
6-3placing_parentheses Maximize expression value by optimal parentheses placement 241. Different Ways to Add Parentheses DP over operator partitions to find max/min expression value.