LeetCode: 15-3Sum 解題紀錄
題目
Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.
Notice that the solution set must not contain duplicate triplets.
Example:
Input: nums = [-1,0,1,2,-1,-4]
Output: [[-1,-1,2],[-1,0,1]]
Input: nums = []
Output: []
題目是給定一個全是由『整數』組成的陣列,而我們的目標就是要找出『任意三個數值加總為 0 的所有答案』,也是題目 3Sum 的意義。
還有,返回的結果不能有重複的答案。
Read More »LeetCode: 15-3Sum 解題紀錄