package Misc; import java.util.*; import java.util.stream.Collectors; public class TwoSumProblem { public static void main(String args[]) { Scanner scan = new Scanner(System.in); System.out.print("Enter the target sum "); int ts= scan.nextInt(); System.out.print("Enter the number of elements in the array "); int n = scan.nextInt(); System.out.println("Enter all your array elements:"); int arr[]= new int[n]; for(int i=0;i hm=new HashMap(); for(int i =0;i temp = hm.entrySet() .stream() .sorted((i1, i2) -> i1.getValue().compareTo( i2.getValue())) .collect(Collectors.toMap( Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new)); int start = 0; int end = nums.length - 1; while (starttarget) end-=1; else if(currSum hm=new HashMap(); for(int i=0;i