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;
}
全部评论

相关推荐

昨天 22:04
江西师范大学
点赞 评论 收藏
分享
03-03 23:42
复旦大学 Java
tongx_:闹呢,这找不到其他人还活不活
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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