10 2,3,4 Sums

这些题基本都是2 pointer。2sum和4sum的变种也会利用hashmap来加速。

1 Two Sum (L56)

L553 Two Sum Closest

167 Two Sum II - input array is sorted (L608 Two Sum IV)

170 Two Sum III - Data structure design

L443 Two Sum II - use 2 pointer to count

15 3 Sum (L57)

16 3 Sum Closest (L59)

259 3 Sum Smaller

18 4 Sum (L58)

Quad combination - pramp mock interview

454 4Sum II

L609 Two Sum V - 小于等于k的count

L587 Two Sum VI - Unique two sum pairs(去重)

L610 Two Sum VII - Difference equals to target

L382 Triangle Count (611 Valid Triangle Number)

653 Two Sum IV - Input is a BST

1679 Max Number of K-Sum Pairs

633 Sum of Square Numbers -- 还能这样2ptr

2491 Divide Players Into Teams of Equal Skill

1099 Two Sum Less Than K

Other related:

L89 k Sum - DP

L90 k Sum II - DFS

532 K-diff Pairs in an Array -- 感觉这题可以转化成2sum,不过这里用了个比较巧妙的解法。

Last updated