18. 4Sum
时间:2016-06-12 21:54:03
收藏:0
阅读:222
1. 问题描述
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.
Note: The solution set must not contain duplicate quadruplets.
For example, given array S = [1, 0, -1, 0, -2, 2], and target = 0. A solution set is: [ [-1, 0, 0, 1], [-2, -1, 1, 2], [-2, 0, 0, 2] ]
Tags:Array Hash Table Two Pointers
Similar Problems: (E) Two Sum (M) 3Sum
2. 解答思路
3. 代码
4. 反思
原文:http://www.cnblogs.com/whl2012/p/5578845.html
评论(0)