diff --git a/Others/3 sum.java b/Others/3 sum.java new file mode 100644 index 000000000..3c008ff78 --- /dev/null +++ b/Others/3 sum.java @@ -0,0 +1,48 @@ +package Others; + +import java.util.Scanner; +import java.util.Arrays; + +/** + * To find triplet equals to given sum in complexity O(n*log(n)) + * + * + * Array must be sorted + * + * @author Ujjawal Joshi + * @date 2020.05.18 + */ + + +class threesum{ + public static void main(String args[]) + { + Scanner sc =new Scanner(System.in); + int n=sc.nextInt(); //Length of an array + + int a[]=new int[n]; + + for(int i=0;i