public static int[] twoSum_binarySearch(int[] numbers, int target) {
        /*
        Algorithm:
        1. Iterate over all the numbers and find the second number by subtracting the first from target
        2. Find the second number from the sorted array.
        3. If second number is found then return index of first and second and second else move to the next number.
         */
        for (int i = 0; i < numbers.length; i++) {
            int first = numbers[0];
            if (first < target) {
                int second = target - first;
                int secondElementIndex = Arrays.binarySearch(numbers, second);
                if (secondElementIndex >= 0) {
                    return new int[]{i, secondElementIndex};
                }
            }
        }
        return new int[0];
    }
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 one solution.
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9, return [0, 1].
java8/src/main/java/com/shekhargulati/leetcode/algorithms/Problem01.java