We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7452e24 commit 4b1ca4eCopy full SHA for 4b1ca4e
src/problems/14.longest-common-prefix.jl
@@ -48,7 +48,7 @@ using LeetCode
48
function longest_common_prefix(strs::Vector{String})::String
49
s1, s2 = minimum(strs), maximum(strs)
50
pos = findfirst(i -> s1[i] != s2[i], 1:length(s1))
51
- return isnothing(pos) ? "" : s1[1:(pos - 1)]
+ return isnothing(pos) ? s1 : s1[1:(pos - 1)]
52
end
53
54
## @lc code=end
0 commit comments