public int duplicate (int[] numbers) { // write code here int[] count=new int[numbers.length]; for(int num:numbers){ count[num]++; } int res=0; for(int i=0;i<numbers.length;i++){ if(count[i]>1){ res=i; return res; } } return -1; }
public int duplicate (int[] numbers) { // write code here int[] count=new int[numbers.length]; for(int num:numbers){ count[num]++; } int res=0; for(int i=0;i<numbers.length;i++){ if(count[i]>1){ res=i; return res; } } return -1; }