예제 #1
0
def fourSum(num, target):
    d = {}
    num1 = list(enumerate_t(num))
    num2 = comb2(num1)
    dict_add_by_distance(d, num2, target)
    return list(
        map(list, frozenset(indices_to_num(get_all_pairs(d, target, 4), num))))
예제 #2
0
def threeSum(num):
    target = 0
    d = {}
    num1 = list(enumerate_t(num))
    num2 = comb2(num1)
    dict_add_by_distance(d, num1, target)
    dict_add_by_distance(d, num2, target)
    return map(list, frozenset(indices_to_num(get_all_pairs(d,target,3),num)))
예제 #3
0
def fourSum(num, target):
    d = {}
    num1 = list(enumerate_t(num))
    num2 = comb2(num1)
    dict_add_by_distance(d, num2, target)
    return list(map(list, frozenset(indices_to_num(get_all_pairs(d,target,4),num))))
예제 #4
0
def twoSum(num, target):
    d = {}
    dict_add_by_distance(d, enumerate_t(num), target)
    return list(frozenset(get_all_pairs(d, target, 2)))[0]
예제 #5
0
def twoSum(num, target):
    d = {}
    dict_add_by_distance(d, enumerate_t(num), target)
    return list(frozenset(get_all_pairs(d, target, 2)))[0]