-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathduplicate.java
More file actions
38 lines (27 loc) · 818 Bytes
/
duplicate.java
File metadata and controls
38 lines (27 loc) · 818 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
import java.util.*;
public class duplicate {
public static void check(int[] nums){
int flag =0;
for(int j=0;j<nums.length;j++){
for(int i=j+1;i<nums.length;i++){
if(nums[j]==nums[i])
flag=1;
}
}
if(flag==1)
System.out.println("true");
else if(flag==0)
System.out.println("false");
}
public static void main(String[] args) {
Scanner sc =new Scanner(System.in);
System.out.println("Enter the size of input");
int n=sc.nextInt();
int nums[]=new int[n];
System.out.println("Enter the numbers");
for(int i=0;i<n;i++){
nums[i]= sc.nextInt();
}
check(nums);
}
}