当前位置: 首页>>代码示例>>Python>>正文


Python Solution.fourSum方法代码示例

本文整理汇总了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)
开发者ID:misaka-10032,项目名称:leetcode,代码行数:11,代码来源:test.py

示例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)
开发者ID:misaka-10032,项目名称:leetcode,代码行数:16,代码来源:test.py

示例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
开发者ID:Albert-Hu,项目名称:leetcode,代码行数:15,代码来源:main.py

示例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)
开发者ID:zhlinh,项目名称:leetcode,代码行数:12,代码来源:test.py

示例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
开发者ID:johnnywsd,项目名称:leetcode_python,代码行数:8,代码来源:test.py

示例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
开发者ID:johnnywsd,项目名称:leetcode_python,代码行数:104,代码来源:test.py


注:本文中的solution.Solution.fourSum方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。