import java.util.*;
public class Dup {
public void duplicate(int a[])
{
int count=0;
for(int i=0;i<a.length;i++)
{
for(int j=i+1;j<a.length;j++)
{
if(a[i]==a[j])
count++; // without using count directly print a[i] at index j
}
if(count==1)
System.out.println(a[i]);
}
}
public static void main(String args[])
{
int n;
Scanner sc=new Scanner(System.in);
n=sc.nextInt();
int a[]=new int[n];
for(int i=0;i<n;i++)
a[i]=sc.nextInt();
Dup d=new Dup();
d.duplicate(a);
}
}
i/p: 6
1 2 3 3 5 1
public class Dup {
public void duplicate(int a[])
{
int count=0;
for(int i=0;i<a.length;i++)
{
for(int j=i+1;j<a.length;j++)
{
if(a[i]==a[j])
count++; // without using count directly print a[i] at index j
}
if(count==1)
System.out.println(a[i]);
}
}
public static void main(String args[])
{
int n;
Scanner sc=new Scanner(System.in);
n=sc.nextInt();
int a[]=new int[n];
for(int i=0;i<n;i++)
a[i]=sc.nextInt();
Dup d=new Dup();
d.duplicate(a);
}
}
i/p: 6
1 2 3 3 5 1
o/p:
1
2
No comments:
Post a Comment