You are viewing a single comment's thread. Return to all comments →
int stringConstruction(char* s) { int max=0;int count=0; for( int i = 0 ; i<strlen(s);i++) { if(s[i]>max) { max = s[i]; } } int *arr = (int*)calloc(max+1,sizeof(int)); for(int i = 0 ; i<strlen(s);i++) { arr[s[i]]++; } for(int i = 0 ; i<=max;i++) { if(arr[i]>0) { count++; arr[i]=0; } } free(arr); return count; }
String Construction
You are viewing a single comment's thread. Return to all comments →