0% found this document useful (0 votes)
52 views

Remove Duplicate Character Using Hash Function PDF

Uploaded by

Reshma Sindhu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

Remove Duplicate Character Using Hash Function PDF

Uploaded by

Reshma Sindhu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

# include <stdio.

h>
# include <stdlib.h>
# define NO_OF_CHARS 256
# define bool int

/* Function removes duplicate characters from the string

This function work in-place and fills null characters

in the extra space left */

char *removeDups(char *str)


{

bool bin_hash[NO_OF_CHARS] = {0};

int ip_ind = 0, res_ind = 0;

char temp;

/* In place removal of duplicate characters*/

while (*(str + ip_ind))

temp = *(str + ip_ind);

if (bin_hash[temp] == 0)

bin_hash[temp] = 1;

*(str + res_ind) = *(str + ip_ind);

res_ind++;

}
ip_ind++;

/* After above step string is stringiittg.

Removing extra iittg after string*/

*(str+res_ind) = '\0';

return str;
}

/* Driver program to test removeDups */

int main()
{

char str[] = "geeksforgeeks";

printf("%s", removeDups(str));

getchar();

return 0;

You might also like