您当前的位置: 首页 >  Java

蓝桥杯刷题JAVA(2)

孑渡 发布时间:2021-03-26 09:48:18 ,浏览量:5

  1. 最长公共前缀

编写一个函数来查找字符串数组中的最长公共前缀。 如果不存在公共前缀,返回空字符串 “”。

class Solution {
    public String longestCommonPrefix(String[] strs) {
        if(strs.length == 0)
        return "";
        int index = 0;
        String result = "";
        int sc = 0;
        for(int p = 1; p             
关注
打赏
1688896170
查看更多评论
0.0566s