import java.util.*; public class ThreeSumProblem { 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> BruteForce(int[] nums,int target) { List> arr = new ArrayList>(); for(int i=0;i temp = new ArrayList<>(); temp.add(nums[i]); temp.add(nums[j]); temp.add(nums[k]); Collections.sort(temp); arr.add(temp); } } } } arr = new ArrayList>(new LinkedHashSet>(arr)); return arr; } public List> TwoPointer(int[] nums, int target) { Arrays.sort(nums); List> arr = new ArrayList>(); int start=0; int end=0; int i = 0; while(i temp = new ArrayList<>(); temp.add(nums[i]); temp.add(nums[start]); temp.add(nums[end]); arr.add(temp); start++; end--; } else if (nums[start]+nums[end]+nums[i]> set = new LinkedHashSet>(arr); return new ArrayList>(set); } public List> Hashmap(int[] nums, int target) { Arrays.sort(nums); Set> ts = new HashSet(); HashMap hm = new HashMap<>(); for(int i=0;ij) { List temp = new ArrayList<>(); temp.add(nums[i]); temp.add(nums[j]); temp.add(t); ts.add(temp); } } } return new ArrayList(ts); } }