diff --git a/Longest Common Prefix - Leetcode 14/Longest Common Prefix - Leetcode 14.go b/Longest Common Prefix - Leetcode 14/Longest Common Prefix - Leetcode 14.go new file mode 100644 index 0000000..51ad323 --- /dev/null +++ b/Longest Common Prefix - Leetcode 14/Longest Common Prefix - Leetcode 14.go @@ -0,0 +1,28 @@ +package solution + +func longestCommonPrefix(strs []string) string { + minLen := len(strs[0]) + for _,v:=range strs{ + if minLen>len(v){ + minLen = len(v) + } + } + str := "" + for i:=0;i