超时:
排序的结果需要用上 后面再修改
class Solution:
def fourSum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[List[int]]
"""
len_nums = len(nums)
result = []
nums.sort()
if len_nums >= 4:
for i in range(len_nums - 3):
for j in range(i+1,len_nums - 2):
for k in range(j+1,len_nums - 1):
numsl = target - nums[i] -nums[j]-nums[k]
if (numsl in nums[k+1 :]) and ([nums[i],nums[j],nums[k],numsl] not in result):
result.append([nums[i],nums[j],nums[k],numsl])
return result