LeetCode1&167.两数之和

1.两数之和 思路:定义一个map,key = 数组中这个值    ;    value = 数组中这个值的下标 遍历一边数组,如果当前这个another = target - nums[i] 在这个map中可以找到,那么直接返回 return vector<int>({hash[another],i}); 这个数的下标和当前这个数的下标,否则就进行记录这个值的索引 注:两个数必定有先后顺序,所以
相关文章
相关标签/搜索