LeetCode#14.最长公共前缀(2019.9.12)

题目

编写一个函数来查找字符串数组中的最长公共前缀。

如果不存在公共前缀,返回空字符串 ""

解答

LeetCode#14.最长公共前缀(2019.9.12)_第1张图片

正确
class Solution {
public:
    string longestCommonPrefix(vector& strs) {
        int len=strs.size();
        if(len==0) return "";
        
        for(int j=0;j
错误
class Solution {
public:
    string longestCommonPrefix(vector& strs) {
        int len=strs.size();
        if(len==0) return "";
        int min=INT_MAX;
        int minx=0;
        for(int i=0;i

LeetCode#14.最长公共前缀(2019.9.12)_第2张图片

求问哪里有问题????

你可能感兴趣的:(LeetCode知识点记录)