2sum、3sum、4sum

这类问题,要先将数组进行排序,然后用夹逼法则(首尾指针)。最终都可以化解为2sum的问题,但是要注意过程中的去重步骤。
leetcode链接:
https://leetcode.com/problems/two-sum/description/
https://leetcode.com/problems/3sum/description/
https://leetcode.com/problems/3sum-closest/description/
https://leetcode.com/problems/4sum/description/
https://leetcode.com/problems/4sum-ii/description/

猜你喜欢

转载自blog.csdn.net/YQMind/article/details/83026975
今日推荐