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 on
//java
class Solution {
public int[] twoSum(int[] nums, int target) {
int [] result=new int [2];
Map<Integer,Integer> map=new HashMap<Integer,Integer>();
for(int i=0;i<nums.length;i++)
{
int n=target-nums[i];
if(map.containsKey(n))
{
result[0]=i;
result[1]=map.get(n);
return result;
}
map.put(nums[i], i);
}
return result;
}
}