You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
# @param {String[]} strs
|
|
# @return {String}
|
|
def longest_common_prefix(strs)
|
|
return '' if strs.empty?
|
|
min, max = strs.minmax
|
|
idx = min.size.times { |i| break i unless min[i] == max[i] }
|
|
min[0...idx]
|
|
end
|