Leetcode每日一题_14
public static String longestCommonPrefix(String[] strs) {
if(strs.length==0||strs==null)return "";
String res=strs[0];
for&nbsp;(int&nbsp;i&nbsp;=&nbsp;1;&nbsp;i&nbsp;<&nbsp;strs.length;&nbsp;i++)&nbsp;{
while(strs[i].indexOf(res)!=0)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;res=res.substring(0,res.length()-1);
}
}
return&nbsp;res;
}
全部评论

相关推荐

06-12 17:07
沈阳大学 Java
AAA射频小张:冬天也发扬下,我怕冷
点赞 评论 收藏
分享
迷茫的大四🐶:自信一点,我认为你可以拿到50k,低于50k完全配不上你的能力,兄弟,不要被他们骗了,你可以的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务