Two Sum Variations
- Two Sum
- Two Sum II - Input Array Is Sorted
- Two Sum III - Data Structure Design
- Two Sum IV - Input is a BST
- Two Sum BSTs
- Two Sum Less Than K
- Two Sum - Less than or equal to target
- Three Sum
- Three Sum Closest
- Three Sum Smaller
- 3sum-smaller
- 3Sum (a variant where you need to find three numbers that add up to zero)
- 3Sum Closest (similar to the above, but you need to find the three numbers that their sum is closest to a target value)
- Four Sum
- Four Sum II
- 4 sum
- 4Sum II (four arrays are given and you need to find the count of all the quadruplets which gives the target sum)
- 4Sum (same as Two Sum, but with four elements instead of two)
- Boats to Save People
- Count Good Meals
- Count Nice Pairs in an Array
- Count Number of Bad Pairs
- Count Number of Pairs with Absolute Difference K
- Divide Players into Teams of Equal Skill
- Finding Pairs with a Certain Sum
- K-Diff Pairs in an Array
- Max Number of K-Sum Pairs
- Number of Excellent Pairs
- Number of Pairs of Strings With Concatenation Equal to Target
- Number of Subsequences That Satisfy the Given Sum Condition
- Tuple with Same Product
- Valid Triangle Number
- Max Dot Product of Two Subsequences (a variation in a sense because it’s about finding two subsequences rather than just two numbers)
- Smallest Range Covering Elements from K Lists (a variation in a sense because it’s about finding two numbers from different lists rather than within the same list)
These variations challenge you to apply the Two Sum problem-solving approach in different scenarios and with varying constraints, thus deepening your understanding and mastery of this basic building block. These all have the underlying idea of looking for two elements that satisfy a certain condition related to their sum, though the specifics may vary.