【文件属性】:
文件名称:leetcode2sumc-four-sum:四和
文件大小:1KB
文件格式:ZIP
更新时间:2021-07-06 17:48:19
系统开源
leetcode
2
和
c
四和
给定一个由
n
个整数组成的数组
nums
和一个整数目标,nums
中是否有元素
a、b、c
和
d
使得
a
+
b
+
c
+
d
=
target?
找到数组中所有唯一的四元组,给出目标的总和。
注意:解决方案集不得包含重复的四元组。
Example:
Given
array
nums
=
[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]
]
执行
:
public
static
List<
List<
Integer
>
>
fourSum(
int
[]
nums,
int
target)
{
List<
List<
Integer
>
>
result
=
new
ArrayList<
List<
Integer
>
>
();
if
(nums
==
null
||
nums
.
length
<
4
)
return
result;
int
n
=
nums
.
le
【文件预览】:
four-sum-master
----README.md(2KB)