Question: For a given array of distinct elements, write a program to find the triplets in a sorted array whose sum is zero and print the


For a given array of distinct elements, write a program to find the triplets in a sorted array whose sum is zero and print the triplets, if it is exist otherwise print "Not Found". 1. limport java.util.*; 2 class Triplets \{ 3 void. findTriplets(int arr[], int n ) 4 v } arr [] , int n) //write your code here \} public static void main(String[] args) \{ Triplets obj = new Triplets () ; Scanner in = new Scanner(System.in); int n= in. nextInt (); int arr[]= new int[n]; for(int i=0;i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
