```
O(n)
===
int dupinarray(int a[],int n)
{
int total=0,i;
for(i=0;i<n;i++)
total+=a[i];
return (n-((n*(n+1)/2)-total));
}
O(n-square)
========
int dupinarray(int a[],int n)
{
int i,j;
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]==a[j])
return a[i];
}
}
}
```

Recommended Topics