3 ms·Programming Interview, Clean Code: Longest Common Prefix4 points by sp24oct 9y agobauerd 9y agodef common_prefix(strs) strs.map(&:chars) .reduce(&:zip) .map(&:flatten) .take_while { |xs| xs.uniq.one? } .map(&:uniq) .join end