> Regexps can help here - dunno about performance
>
> class String
>   def lcommon(s)
>     len = s.length
>     Regexp.new("^" << s.gsub( /./, '(?:\\&' ) << ( ")?" * 
> len ) ).match(self)[0]
>   end
> end
>
> > s1 = "abcxxxxxx"
> => "abcxxxxxx"
> > s2 = "abcdezzzzz"
> => "abcdezzzzz"
> > s1.lcommon s2
> => "abc"
>
> :-)

evil!

Depending on the complexity of Regexp.new(), this may still be O(n).
The performance/constant upon that would be low/high, I suppose.
(specifically the gsub)

+--- Kero ------------------------- kero@chello@nl ---+
|  all the meaningless and empty words I spoke        |
|                       Promises -- The Cranberries   |
+--- M38c --- http://members.chello.nl/k.vangelder ---+