本文整理汇总了Python中solution.Solution.fourSum方法的典型用法代码示例。如果您正苦于以下问题:Python Solution.fourSum方法的具体用法?Python Solution.fourSum怎么用?Python Solution.fourSum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类solution.Solution
的用法示例。
在下文中一共展示了Solution.fourSum方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_2
# 需要导入模块: from solution import Solution [as 别名]
# 或者: from solution.Solution import fourSum [as 别名]
def test_2():
sol = Solution()
nums, target = [-3, -2, -1, 0, 0, 1, 2, 3], 0
ans = [[-3, -2, 2, 3], [-3, -1, 1, 3], [-3, 0, 0, 3], [-3, 0, 1, 2],
[-2, -1, 0, 3], [-2, -1, 1, 2], [-2, 0, 0, 2], [-1, 0, 0, 1]]
assert sorted(sol.fourSum(nums, target)) == sorted(ans)
nums, target = [-7, -5, 0, 7, 1, 1, -10, -2, 7, 7, -2, -6, 0, -10, -5, 7, -8, 5], 28
ans = [[7, 7, 7, 7]]
assert sorted(sol.fourSum(nums, target)) == sorted(ans)
示例2: test_1
# 需要导入模块: from solution import Solution [as 别名]
# 或者: from solution.Solution import fourSum [as 别名]
def test_1():
sol = Solution()
nums, target = [1, 0, -1, 0, -2, 2], 0
ans = [[-1, 0, 0, 1], [-2, -1, 1, 2], [-2, 0, 0, 2]]
assert sorted(sol.fourSum(nums, target)) == sorted(ans)
nums, target = [0, 0, 0, 0], 0
ans = [[0, 0, 0, 0]]
assert sorted(sol.fourSum(nums, target)) == sorted(ans)
nums, target = [0, 1, 2], 0
ans = []
assert sorted(sol.fourSum(nums, target)) == sorted(ans)
nums, target = [1, -1, -1, 0], -1
ans = [[-1, -1, 0, 1]]
assert sorted(sol.fourSum(nums, target)) == sorted(ans)
示例3: main
# 需要导入模块: from solution import Solution [as 别名]
# 或者: from solution.Solution import fourSum [as 别名]
def main():
nums = None
solution = Solution()
for line in stdin:
if nums == None:
nums = map(lambda s: int(s), line.split())
else:
target = int(line)
lists = solution.fourSum(nums, target)
for _list in lists:
print "(%d, %d, %d, %d)" % (_list[0], _list[1], _list[2], _list[3]),
print
nums = None
示例4: Solution
# 需要导入模块: from solution import Solution [as 别名]
# 或者: from solution.Solution import fourSum [as 别名]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from solution import Solution
inpt = [1, 0, -1, 0, -2, 2]
# inpt = [-1, 0, 1, 2, -1, -4]
target = 0
sol = Solution()
res = sol.fourSum(inpt, target)
print(res)
示例5: test1
# 需要导入模块: from solution import Solution [as 别名]
# 或者: from solution.Solution import fourSum [as 别名]
def test1(self):
s = Solution()
num = [-1, 3, 5, 7, -2, 4, -6, 8]
target = 9
res = s.fourSum(num, target)
print res
示例6: test2
# 需要导入模块: from solution import Solution [as 别名]
# 或者: from solution.Solution import fourSum [as 别名]
#.........这里部分代码省略.........
85735982,
90399615,
-86251609,
-68167910,
-95327478,
90586275,
-99524469,
16999817,
27815883,
-88279865,
53092631,
75125438,
44270568,
-23129316,
-846252,
-59608044,
90938699,
80923976,
3534451,
6218186,
41256179,
-9165388,
-11897463,
92423776,
-38991231,
-6082654,
92275443,
74040861,
77457712,
-80549965,
-42515693,
69918944,
-95198414,
15677446,
-52451179,
-50111167,
-23732840,
39520751,
-90474508,
-27860023,
65164540,
26582346,
-20183515,
99018741,
-2826130,
-28461563,
-24759460,
-83828963,
-1739800,
71207113,
26434787,
52931083,
-33111208,
38314304,
-29429107,
-5567826,
-5149750,
9582750,
85289753,
75490866,
-93202942,
-85974081,
7365682,
-42953023,
21825824,
68329208,
-87994788,
3460985,
18744871,
-49724457,
-12982362,
-47800372,
39958829,
-95981751,
-71017359,
-18397211,
27941418,
-34699076,
74174334,
96928957,
44328607,
49293516,
-39034828,
5945763,
-47046163,
10986423,
63478877,
30677010,
-21202664,
-86235407,
3164123,
8956697,
-9003909,
-18929014,
-73824245,
],
-236727523,
)
res = s.fourSum(num, target)
print res