A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© Miss_Allsunday 中级黑马   /  2017-6-18 12:23  /  1681 人查看  /  2 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

15. 3Sum
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.
Note: The solution set must not contain duplicate triplets.
For example, given array S = [-1, 0, 1, 2, -1, -4],A solution set is:[  [-1, 0, 1],  [-1, -1, 2]]
给一个数组S包含n个整数,有没有这样的元素a, b, c使得a + b + c = 0? 找出独特的组合使它们的和为零。
注意:结果的组合不能重复。

举例,给一个数组 S = [-1, 0, 1, 2, -1, -4],

答案组合为:
[
   [-1, 0, 1],
   [-1, -1, 2]
]

你需要完成以下函数:
/**
* Return an array of arrays of size *returnSize.
* Note: The returned array must be malloced, assume caller calls free().
*/
int** threeSum(int* nums, int numsSize, int* returnSize) {

}


这道题的网址是:“https://leetcode.com/problems/3sum/#/description“

评分

参与人数 1黑马币 +5 收起 理由
zhao543 + 5 很给力!

查看全部评分

2 个回复

倒序浏览
占楼,待发答案。
回复 使用道具 举报
你的代码 打动了我
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马