标签:bsp The integer other nta etc contains put tps
int [] two_num(int [] nums,int target){ HashMap<Integer, Integer> num_indx = new HashMap<Integer, Integer>(); int [] ans = new int [2]; for(int i=0;i<nums.length;i++){ int another = target - nums[i]; if(num_indx.containsKey(another)){ ans[0] = i; ans[1] = num_indx.get(another); return ans; } num_indx.put(nums[i],i); } return ans; }
https://leetcode-cn.com/problems/two-sum/
这个要注意读题,明确说明是两数之和。。
标签:bsp The integer other nta etc contains put tps
原文地址:https://www.cnblogs.com/superxuezhazha/p/12264495.html