Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Files

Latest commit

0120d35 · Mar 14, 2018

History

History

0018.4sum

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Mar 14, 2018
Mar 14, 2018
Jul 29, 2017

README.md

题目

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]
]

解题思路

我解答这一题的思路,和15. 3Sum的思路一样的,就是多套了一层循环而已。

总结

未知的问题,可以转换成已知的问题来求解。