Beispiel #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))))
Beispiel #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)))
Beispiel #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))))