| 4 | import java.util.*; |
| 5 | public class Two_Sum { |
| 6 | public static void main(String args[]) |
| 7 | { |
| 8 | try (Scanner sc = new Scanner(System.in)) { |
| 9 | int n = sc.nextInt(); |
| 10 | // length of the array is taken |
| 11 | int a[] = new int[n]; |
| 12 | for(int i = 0; i < n; i++) |
| 13 | { |
| 14 | a[i] = sc.nextInt(); |
| 15 | } |
| 16 | int target=sc.nextInt(); |
| 17 | // target value is initialzized |
| 18 | int array[] = new int[2]; |
| 19 | a=twoSum(array,target); |
| 20 | // method is called |
| 21 | for(int i=0;i<2;i++) |
| 22 | { |
| 23 | System.out.print(a[i]+" "); |
| 24 | } |
| 25 | System.out.println(); |
| 26 | } |
| 27 | } |
| 28 | public static int[] twoSum(int[] n, int target) { |
| 29 | Map<Integer,Integer> nm=new HashMap<>(); |
| 30 | // hashmap is created to store the array elements |