leetcode 1.Two Sum 、167. Two Sum II - Input array is sorted 、15. 3Sum 、16. 3Sum Closest 、 18. 4Su...

 1.two sum 用hash来存储数值和对应的位置索引,通过target-当前值来获得需要的值,然后再hash中寻找 错误代码1: Input: [3,2,4] 6 Output: [0,0] Expected: [1,2] 同一个数字不能重复使用,但这个代码没排除这个问题 class Solution { public: vector<int> twoSum(vector<int>&
相关文章
相关标签/搜索