Simplify the process of finding the minimum length
This commit is contained in:
parent
d09a4d3eb0
commit
bb2ac41656
1 changed files with 1 additions and 6 deletions
|
@ -2,12 +2,7 @@
|
|||
# @return {String}
|
||||
def longest_common_prefix(strs)
|
||||
# Find min length
|
||||
min_length = strs[0].length
|
||||
strs.each do |st|
|
||||
if st.length < min_length
|
||||
min_length = st.length
|
||||
end
|
||||
end
|
||||
min_length = strs.map{|s| s.length}.min()
|
||||
|
||||
res = ""
|
||||
for i in 0..min_length - 1 do
|
||||
|
|
Loading…
Reference in a new issue