public class Solution {
    public int[] twoSum(int[] nums, int target) {
        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
        for (int i = 0; i < nums.length; i++)
            map.put(nums[i], i+1);

        for (int j = 0; j < nums.length; j++) {
            Integer idx2 = map.get(target - nums[j]);
            if (idx2 != null && idx2 != j+1)
                return new int[]{j+1, idx2};
        }
        return null;       
    }
}

@@ -456,8 +456,371 @@
     %7D%0A%7D%0A
+%0A// solution 2%0Apublic class Solution %7B%0A    public int%5B%5D twoSum(int%5B%5D nums, int target) %7B%0A%09%09Map%3CInteger, Integer%3E map = new HashMap%3CInteger, Integer%3E();%0A%09%09%0A%09%09for(int i = 0; i %3C nums.length; i++) %7B%0A%09%09%09if(map.containsKey(target - nums%5Bi%5D)) %0A%09%09%09%09return new int%5B%5D %7Bmap.get(target - nums%5Bi%5D), i + 1%7D;%0A%09%09%09else%0A%09%09%09%09map.put(nums%5Bi%5D, i + 1);%0A%09%09%7D%0A%09%09return null;    %0A    %7D%0A%7D%0A

Update 001.java