Question: Given an array of unique positive integers, write a function findSums that takes the array input and Creates a hashtable called hashT and inserts all

 Given an array of unique positive integers, write a function findSumsthat takes the array input and Creates a hashtable called "hashT" and

Given an array of unique positive integers, write a function findSums that takes the array input and Creates a hashtable called "hashT" and inserts all the elements of the input array in the hashtable. Finds pairs of elements in the hashtable whose sum is another element (sum) in the hashtable and print the pairs in the console. Returns another hashtable names "sums" of those sum elements. 1. 2. 3. For example: Input: [1,5,4,6,7,9] Output: [6,5,7,9] Explanation : 6 1 + 5 ; 5 1 + 4 ; 7-1 + 6 ; 9 5 + 4 --Class Template import java.util.HashSet; public class FindSum { public static void main(String args[])l int[] arr - ( 1, 5, 4, 6, 7, 9 ); HashSet resfindSums (arr); System.out.println(res.toString)) II Should return [6,5,7,9] public static HashSet findSums (int[] elements)( HashSet itialize a hashtable HashSet hashtable-new HashSet

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!