Quote:
for(i = 0 ; i<26 ; temp[i]=0 , ++i);
Assigns zero to every (26) items of
temp
.
Quote:
for(i = 0 ; str1[i] ; ++i)
temp[str1[i] - 'A'] = 1;
for(i = 0 ; str2[i] ; ++i)
temp[ str2[i] - 'A'] = 1 ;
for(i = 0 ; str3[i] ; ++i)
temp[str3[i] - 'A'] = 1;
Assigns one to the element of
temp[i]
having index correpondig to the letters of the passed strings, that is
"ABCD" => temp[0]=temp[1]=temp[2]=temp[3]=1
"ACDS" => temp[0]=temp[2]=temp[3]=temp[18]=1
...
Quote:
for(i = k = 0 ; i<26 ; ++i)
if(temp[i])
arr[k++] = i + 'A';
Builds the string
arr
using only the letters corresponding to index of non-zero
temp
items. That is
if temp[i] == 1 => append character[i] to arr
(e.g
temp[0] == 1 => append 'A' to arr
).
Quote:
arr[k] = '\0';
return k;
Terminates the
arr
string and returns arr length.
The overall result is a string containing, in alphabetic order just one occurrence (hence 'unique') of every character of the three passed string, that is
{"ABCD"," ACDS","KLMN"} => "ABCDKLMNS"
I hope my (brain compiled) code analysis is correct.