ak89
BAN USER1) Create a int array of size 26 and intialize all the elements by 0. Also intialize a counter by 0.
2) Then start reading each word's alphabet and subtract ascii code of 'a'. Eg let the first work be "ball". Then read 'b'- 'a' (which =1). Let this value be x
3) now go to a[x] and check the value there. If the value==0. then a[x]= counter and counter++.
else do not do anything.
4) After reading all the words once we will have the order in which the alphabets appear in those words.
Now create one new character array (say , char solution[])for 26 chars. Which will be the answer.
Read array a[] created above (which has the order of the alphabets) in the following sense:
if a[0]=7, this means alphabet a comes 7th. Therefore go to solution[7] store 'a' and so on.
Thats it!!!!
The only problem here is overflow issue.
- ak89 September 16, 2012