#include <stdio.h>
#include <stdint.h>
void remove_duplicates(char *str) {
//Your logic here
uint8_t has_appeared[128] = {0};
int len = 0;
while (*(str+len) != '\0') ++len;
for (int i = 0; i < len; ++i) {
if (!has_appeared[*(str+i)]) {
has_appeared[*(str+i)] = 1;
} else {
for (int j = i; j < len; ++j) {
*(str+j) = *(str+j+1);
}
--len;
--i;
}
}
}
int main() {
char str[101];
fgets(str, sizeof(str), stdin);
// Remove newline
uint8_t i = 0;
while (str[i]) {
if (str[i] == '\n') {
str[i] = '\0';
break;
}
i++;
}
remove_duplicates(str);
printf("%s", str);
return 0;
}
Input
programming
Expected Output
progamin