package aRray;
import java.util.*;
public class practicalArray {
public static int findDuplicate(int arr[], int size) {
for(int i = 0 ; i < size; i++) {
for(int j = i+1; j < size; j++) {
if(arr[i] == arr[j]) {
return arr[i];
}
}
}
return -1;
}
public static void main(String [] args) {
Scanner scan = new Scanner(System.in);
int size = scan.nextInt();
int [] arr = new int[size];
for(int i = 0; i < size; i++) {
arr[i] = scan.nextInt();
}
int result = findDuplicate(arr,size);
System.out.println(result);
//print process
}
}
Comments
Post a Comment