See More

package algorithm.search; import java.util.HashMap; import java.util.Map; /** * The type Two number with given sum. */ public class TwoNumberWithGivenSum { /** * Two numbers int [ ]. * * @param arr the arr * @param sum the sum * @return the int [ ] */ public static int[] twoNumbers(int[] arr, int sum){ int[] ans = new int[2]; Map map = new HashMap(); int l = arr.length; for(int i=0;i