Help in graph problem

Revision en1, by wocagav, 2021-09-03 10:26:07

There is an array of strings. Suppose there is a string whose last character matches with the first character of another string. In that case those two form a ring. You have the find the maximum length of the ring formed by the strings in the array. Let me explain the problem with an example. Suppose the array of strings is {ear, track, tired, rat, doe}. Here the maximum ring will be ear->rat->tired->doe>ear. So, the length will be 4.

If possible please provide code also .

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English wocagav 2021-09-03 10:26:07 503 Initial revision (published)