#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
void remove_duplicates(char *s) {
for (int i = 0; i < strlen(s); i++) {
for (int j = i + 1; s[j] != '\0'; j++) {
if (s[j] == s[i]) {
for (int k = j; s[k] != '\0'; k++) {
s[k] = s[k + 1];
}
j--;
}
}
}
}
bool contain_same_characters_and_order(char s1[], char s2[]) {
char *s1_tmp = (char *)malloc((strlen(s1) * sizeof(char)) + 1);
char *s2_tmp = (char *)malloc((strlen(s2) * sizeof(char)) + 1);
strcpy(s1_tmp, s1);
strcpy(s2_tmp, s2);
remove_duplicates(s1_tmp);
remove_duplicates(s2_tmp);
bool b = true;
for (int i = 0; i < strlen(s1_tmp); i++) {
if (s1_tmp[i] != s2_tmp[i]) {
b = false;
break;
}
}
free(s1_tmp);
free(s2_tmp);
return b;
}
int main() {
char s1[] = "c programming";
char s2[] = "ccc proooogramminggggg";
if (contain_same_characters_and_order(s1, s2))
puts("yes");
else
puts("no");
}
/*
run:
yes
*/