maintain an array indexed on alphabets 'a' to  'z'.
now count the occurence of each character taking *last character* of each
string
{"asdsb","csasaa", "bssssc", bddddc"}
in this case
arr[a]=1;
arr[b]=1;
arr[c]=2;

now start with each sting let first character be first and last character be
last
while (strings)
{
if(arr[first ]==0)
return false;

if(arr[first]==1)
{
if(first==last)
return false;
}

else{
arr[first--];
}
}/*end while
if at the end all elements of arr =0 then return true
 else
return false;








On Sat, Aug 13, 2011 at 9:44 PM, Yasir <yasir....@gmail.com> wrote:

> An array of strings is given and you have to find out whether a circular
> chain with all character can be formed or not?
> Circular chain is formed in way that:   if last char of a string is equal
> to first char of another string then it can be joined.:
> like axxxxb  bxxxxxc  ===>   axxxxxbbxxxxxc  (Notice that it got joined at
> b)
>
> example
>  {"asdsb","csasaa", "bssssc"}
> Answer:   TRUE
>
>  {"asdsb","csasaa", "bssssc", bddddc"}
> Answer: FALSE
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/WGN5GLyIP_QJ.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Regards,
Kamakshi
kamakshi...@gmail.com

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to