[Leetcode] 14. Longest Common Prefix
来源:互联网 发布:微博发长图用什么软件 编辑:程序博客网 时间:2024/05/14 07:45
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 == null || strs.length == 0) return ""; String longest = strs[0]; for(int i = 1; i < strs.length; i++){ int j = 0; while(j < longest.length() && j < strs[i].length() && longest.charAt(j) == strs[i].charAt(j)){ j++; } longest = longest.substring(0, j); } return longest; }}
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
- 【ACM之旅】选择计算
- windows下使用pm2
- vtk filter 的写法
- DFS所用到的奇偶剪枝
- poj1083 思维题
- [Leetcode] 14. Longest Common Prefix
- 实用数据结构---图的操作和算法
- C++ pthread cond_wait 和 cond_broadcast的使用
- matlab数组中求最大的几个数并返回其位置
- 安装visul studio 2010或2008失败的解决方案
- Linux Tar Command
- Java中静态变量与实例变量的区别
- 整数数字之和
- 出现错误“tcnative-1.dll: Can't load AMD 64-bit .dll on a IA 32-bit platform”的解决办法