-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindTriplets.java
More file actions
50 lines (40 loc) · 1.21 KB
/
Copy pathFindTriplets.java
File metadata and controls
50 lines (40 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
public class FindTriplets{
public static void main(String args[])
{
Scanner scn=new Scanner(System.in);
int n=scn.nextInt();
ArrayList<Integer> arr = new ArrayList<Integer>();
HashMap<Integer, Integer> m = new HashMap<Integer, Integer>();
for(int i=0;i<n;i++)
{
int temp = scn.nextInt();
if(!m.containsKey(temp))
{
arr.add(temp);
m.put(temp, 1);
}
}
int triplets=0;
ArrayList<Integer> ans = new ArrayList<Integer>();
for(int i = 0; i < arr.size() - 2; i++)
{
ans.add(arr.get(i));
ans = findDup(arr, i , ans);
for(int j = 0; j < ans.size(); j++)
System.out.print(ans.get(j) + " ");
System.out.println();
ans.clear();
}
System.out.println(triplets);
}
private static ArrayList<Integer> findDup(ArrayList<Integer> arr, int t, ArrayList<Integer> ans) {
return ans;
}
}