This site features a collection of common technical interview questions gathered by a group of programmers who have been through, and given, lots of technical interviews. There is an emphasis on C++ and game programming technical interviews, but most of the questions are relevant to any technical interview.
Remove Duplicates

Write a function to remove duplicate entries from a sorted array.

void RemoveDuplicates(int *pArray,int arraySize)
{

2 Comments so far
Leave a comment

int Reduce(int * pArray, int len)
{
// make sure we got a valid pointer
if (!pArray) return 0;

// make sure we have an array >= 2 in length, otherwise the array is “unique” by definition
if (len

if this is a *sorted* array then if there are any duplicates they should immediately follow the “original” entry, ie:

0,1,3,5,6,[6],9,10,14,[14],[14], etc.

if (pArray[idx] == pArray[idx-1])
delete(pArray[idx]);



Leave a comment
If you are including code in your comment, place it within a <div class='code'></div> tag for better formatting.


Do you have a technical interview question you would like to submit? Some tips you would like to pass on? Just want to say hi? Feel free to contact us