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))))
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)))
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))))
def twoSum(num, target): d = {} dict_add_by_distance(d, enumerate_t(num), target) return list(frozenset(get_all_pairs(d, target, 2)))[0]