leecode笔记 KSUM

leecode题号:已完成 1Two Sum ,15 3Sum   

未完成  2,16,18

1. 

Given an array of integers, return indices of the two numbers such that they add up to a specific target.

You may assume that each input would have exactly one solution, and you may not use the same element twice.

解法1 复杂度O(n^2) for嵌套


15. 3Sum

Given an array S of n integers, are there elements abc in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.

排序-->for循环(取队列中的一个数)-->逐一测左+右+target是否为0

你可能感兴趣的:(leecode,array)