Leetcode||14.Longest Common Prefix
来源:互联网 发布:c语言编写驱动程序 编辑:程序博客网 时间:2024/05/17 03:13
4. Longest Common Prefix
- Total Accepted: 132475
- Total Submissions: 440240
- Difficulty: Easy
- Contributors: Admin
Write a function to find the longest common prefix string amongst an array of strings.
代码如下:
public class Solution { public String longestCommonPrefix(String[] strs) { if (strs.length==0) {return "";}for (int i = 0; i < strs[0].length(); i++) {for (int j = 0; j < strs.length; j++) {if (strs[j].length()<=i||strs[j].charAt(i)!=strs[0].charAt(i)) {return strs[0].substring(0, i);}}} return strs[0]; }}
0 0
- [leetcode] 14. Longest Common Prefix[leetcode] 14. Longest Common Prefix
- [LeetCode]14.Longest Common Prefix
- LeetCode 14. Longest Common Prefix
- LeetCode --- 14. Longest Common Prefix
- LeetCode 14.Longest Common Prefix
- [Leetcode] 14. Longest Common Prefix
- 【leetcode】14. longest common prefix
- [leetcode] 14.Longest Common Prefix
- [leetcode] 14. Longest Common Prefix
- LeetCode - 14. Longest Common Prefix
- Leetcode-14. Longest Common Prefix
- Leetcode 14. Longest Common Prefix
- 14. Longest Common Prefix LeetCode
- leetcode 14. Longest Common Prefix
- leetcode 14. Longest Common Prefix
- leetcode 14. Longest Common Prefix
- LeetCode--14. Longest Common Prefix
- Leetcode 14. Longest Common Prefix
- win7 64位操作系统安装python2.7,numpy,matplotlib,scipy,scikit-learn,pandas等
- 数据库:SQlite3的C接口相关函数
- Java断言:assert
- Android弹幕功能实现,模仿斗鱼直播的弹幕效果
- 4.一些关简单的键字.package,private,this
- Leetcode||14.Longest Common Prefix
- “玲珑杯”ACM比赛 Round #4 E题
- dht11模块的学习
- 嵌入式驱动编写-第一个驱动程序
- 文件属性分析
- 高低压为什么不能共地的一个解释
- 项目版本不同导致Eclipse报错问题——关于在JDK1.7环境中,运行JDK1.8环境下编写的项目。
- C语言模拟考|Proper Fraction
- Python的垃圾回收