Longest Common Prefix:Write a function to find the longest common prefix string amongst an array of strings.
题意:查找一个字符串数组中的字符串的最长公共子序列。
思路:首先查找字符串数组中,字符串长度最小的字符串的索引,然后在逐位判断。
代码:
public String longestCommonPrefix(String[] strs) { String result = ""; if (strs.length==0) return result; if(strs.length==1) return strs[0]; int index=0; for(int i=0;i