public static int[] twoSumWithHash(int[] numbers, int target) {
        int[] index = new int[2];
        // save target - val to a hashtable
        HashMap<Integer, ArrayList<Integer>> hash = new HashMap<>();
        for (int i = 0; i < numbers.length; ++i) {
            if (!hash.containsKey(target - numbers[i])) {
                ArrayList<Integer> list = new ArrayList<Integer>();
                list.add(i);
                hash.put(target - numbers[i], list);
            } else {
                ArrayList<Integer> list = hash.get(target - numbers[i]);
                list.add(i);
            }
        }
        // search in inverse direction, and consider the two index should not be same
        // also we need consider duplicate number keys
        for (int j = numbers.length - 1; j > 0; --j) {
                System.out.print(hash.get(numbers[j]) + " " + j + "\n");
            if (hash.containsKey(numbers[j])) {
                ArrayList<Integer> list = hash.get(numbers[j]);
                for (int k : list) {
                    if (k != j) {
                        index[0] = k + 1;
                        index[1] = j + 1;
                        return index;
                    }
                }
            }
        }
        return index;
    }