public class Solution {
    public String longestCommonPrefix(String[] strs) {
        if(strs == null || strs.length == 0)    return "";
        String pre = strs[0];
        int i = 1;
        while(i < strs.length){
            while(strs[i].indexOf(pre) != 0)
                pre = pre.substring(0,pre.length()-1);
            i++;
        }
        return pre;
    }
}

相关文章:

  • 2022-03-07
  • 2021-09-18
  • 2021-09-14
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-25
  • 2022-02-26
  • 2022-01-18
  • 2021-08-02
  • 2021-09-25
  • 2022-02-24
  • 2021-08-26
相关资源
相似解决方案