in reply to Re: Seeking the longest string in an array
in thread Seeking the longest string in an array

I don't think your code is correct. You are only removing the items that are equal to some prefix of the currently processed $word. You should delete all substrings, not only the prefixes. That would make your solution O(N*log N + N*M*M). We don't know the expected N and M, but this makes the M much more important.

Jenda
We'd like to help you learn to help yourself
Look around you, all you see are sympathetic eyes
Stroll around the grounds until you feel at home
   -- P. Simon in Mrs. Robinson

  • Comment on Re^2: Seeking the longest string in an array

Replies are listed 'Best First'.
Re^3: Seeking the longest string in an array
by ikegami (Patriarch) on Dec 11, 2004 at 23:10 UTC
    Shoot, you're right. I misunderstood what his program did.