package leetcode;

import java.util.Arrays;

/**
 * https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/
 */
public class Problem167 {
    public int[] twoSum(int[] numbers, int target) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem167 prob = new Problem167();
        System.out.println(Arrays.toString(prob.twoSum(new int[]{2, 7, 11, 15}, 9)));
    }
}

@@ -34,17 +34,116 @@
 il.Array
-s
+List;%0Aimport java.util.Arrays;%0Aimport java.util.HashMap;%0Aimport java.util.List;%0Aimport java.util.Map
 ;%0A%0A/**%0A 
@@ -303,35 +303,868 @@
     
-// TODO%0A        return null
+int%5B%5D array = new int%5B2%5D;%0A        Map%3CInteger, List%3CInteger%3E%3E map = new HashMap%3C%3E();%0A        for (int i = 0; i %3C numbers.length; i++) %7B%0A            if (!map.containsKey(numbers%5Bi%5D)) %7B%0A                List%3CInteger%3E list = new ArrayList%3C%3E();%0A                list.add(i + 1);%0A                map.put(numbers%5Bi%5D, list);%0A            %7D else %7B%0A                map.get(numbers%5Bi%5D).add(i + 1);%0A            %7D%0A        %7D%0A        for (int i = 0; i %3C numbers.length; i++) %7B%0A            int a = target - numbers%5Bi%5D;%0A            if (map.containsKey(a)) %7B%0A                for (int idx : map.get(a)) %7B%0A                    array%5B0%5D = Math.min(i + 1, idx);%0A                    array%5B1%5D = Math.max(i + 1, idx);%0A                    if (array%5B0%5D != array%5B1%5D) %7B%0A                        return array;%0A                    %7D%0A                %7D%0A            %7D%0A        %7D%0A        return array
 ;%0A  
@@ -1343,16 +1343,100 @@
 , 9)));%0A
+        System.out.println(Arrays.toString(prob.twoSum(new int%5B%5D%7B0, 0, 3, 4%7D, 0)));%0A
     %7D%0A%7D%0A

Solve problem 167