Interview Question

Software Engineer Interview(Student Candidate) Pune (India)

Write, efficient code for extracting unique elements from a

  sorted list of array. e.g. (1, 1, 3, 3, 3, 5, 5, 5, 9, 9, 9, 9) -> (1, 3,
Answer

Interview Answer

1 Answer

4

{
int a[10]={1, 2, 4, 4, 7, 8, 9, 14, 14, 20};
int i;
for (i = 0;i<9;i++)
{
if (a[i] != a[i+1])
printf("%d\n",a[i]);
}
return 0;
}

Interview Candidate on Mar 1, 2010

Add Answers or Comments

To comment on this, Sign In or Sign Up.