Using two maps one processes ++ and the other processes -- operation;
#include <stdlib.h>
char a[] = {'a','b','c','d','e'};
char b[] = {'a','b','d','d','e'};
int map[128];
void compare(char* a,char* b, int len){
int i;
for(i = 0; i < len; i++){
map[a[i]]++;
}
for(i = 0; i < len; i++){
map[b[i]]--;
}
}
int isEqual(){
int i = 0;
for(; i < 256; i++){
if(map[i] != 0){
return -1;
}
}
return 1;
}
int main(){
compare(a, b, 5);
int result = isEqual();
printf("%d", result);
}