天天看点

[Leetcode] 4Sum

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:

elements in a quadruplet (a,b,c,d)

must be in non-descending order.

(ie, a ≤ b ≤ c ≤ d)

the solution set must not contain duplicate quadruplets.

跟3sum一样,先用两层循环,注意去重。