C program to remove duplicates in an array

C program to remove duplicates in an array

Removing duplicates from an array is a very common interview question. For your reference, we have written the program and its compiled and tested.  If you are preparing for the interview make sure you learn the code logic and try implementing it on your own.


The core logic to remove duplicates is to iteratively check for the item existence. For this, we will use one additional temporary array and a few counter variables i, j, k, and flag variable exists. In the program we transfer items one after the other from one array to other, while we do this we make sure its not already in the new array. 

	Program to remove duplicate numbers from an array
	Author 			: 		Krishna Teja G S
	Repository		:		github.com/packetprep/coding-questions
	Website			: 		packetprep.com


int main(){

	int arr[] = {100, 5, 201, 13, 5, -8,12,-8,3,-8}; 
	int i,j,k,key,exists;
	int arr_size = sizeof(arr)/sizeof(int); 
	int arr_2[100]={0};

	printf("Elements: \n");