forked from joharbatta/DataStructure-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrsdup.java
More file actions
44 lines (41 loc) · 903 Bytes
/
Copy pathArrsdup.java
File metadata and controls
44 lines (41 loc) · 903 Bytes
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
import java.util.*;
public class Arrsdup
{
public static void main(String args[])
{
int c=0;
Scanner s=new Scanner(System.in);
int n=s.nextInt();
s.nextLine();
char arr[]=new char[n];
// String arr1[]=new String[n];
for(int i=0;i<n;i++)
{
arr[i]=
s.next().charAt(0);
}
// for(int i=0;i<n;i++)
// {
// arr1[i]=arr[i];
// }
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
if(arr[i]==arr[j] && i!=j)
{
c++;
}
}
if(c>=1)
{
System.out.print(arr[i]+" ");
}
c=0;
}
// for(int i=0;i<n;i++)
// {
// System.out.print(arr1[i]+" ");
// }
}
}