问题
Write a function that takes in a non-empty array of distinct integers and an integer representing a target sum. The function should find all triplets in the array that sum up to the target sum and return a two-dimensional array of all these triplets. The numbers in each triplet should be ordered in ascending order, and the triplets themselves should be ordered in ascending order with respect to the numbers they hold. If no three numbers sum up to the target sum, the function should return an empty array.
编写一个函数,该函数接受不同整数的非空数组和表示目标和的整数。函数应该在数组中找到所有三元组的总和,并返回所有这些三元组的二维数组。每个三元组中的数字应按升序排列,三元组本身应按其持有的数字按升序排列。如果没有三个数字的和达到目标和,函数应该返回一个空数组。
例如ÿ