Skip to content

Latest commit

 

History

History
21 lines (16 loc) · 496 Bytes

TwoSum.md

File metadata and controls

21 lines (16 loc) · 496 Bytes

TwoSum

Returns indices of two numbers in an array that sum to a target

To use this class, just use TwoSum.twoSum(array, target) inside the main class

public int[] twoSum(int[] array, int target) {
        //returns the result in an array form
}

Example code, for understanding:

public static void main(String[] args) {
        TwoSum twoSum = new TwoSum();
        int[] result = twoSum.twoSum(new int[]{2,7,11,15}, 90);
        System.out.println(result);
}