给一个int型数组无序,从数组中选出两数字,使得这两数字之和为target,将这两数字的下标作为数组返回。(一定存在一个解)
注意:对代码进行优化,可能会超时。
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9,
return [0, 1]. ##
注意:对代码进行优化,可能会超时。
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9,
return [0, 1]. ##