49.leetcode题目18. 4Sum

题目:

Given an array S of n integers, are there elements abc, 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.

    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)
分析:

某次是不是做过一个三个数之和为target的题?

调用了threeSum的函数(略做修改),但是编译出现错误:

Line 3: stray ‘\357’ in program

原因是:出现了非法字符;

修改之后出现错误:

Run Code Status: Runtime Error

原因是:nums.size()的结果是unsigned类型的,for(int i=0;i

accept,but~



你可能感兴趣的:(leetcode)