Dynamic Programming, Recursion, Competitive Programming, Leetcode, 3sum.
# Compute 2sum for the first part two_sum = two_sums(arr[:-1]) # Check for all the pairs of numbers in the first part that conforms # to the given sum. c2 = list(map(lambda t: (t[0], t[1], arr[-1]), two_sum.get(sum - arr[-1], []))) # Merge two solutions return c1 + c2 The cached version is somewhat