码迷,mamicode.com
首页 > 其他好文 > 详细

18. 4Sum

时间:2016-06-12 21:57:09      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:

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. 反思

18. 4Sum

标签:

原文地址:http://www.cnblogs.com/whl2012/p/5578845.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!