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 "";
if(strs.length==1)return strs[0];
String commonPrefix=strs[0];
boolean isContinue=true;
while(isContinue)
{
for(int i=1;i<strs.length;i++)
{
if(!strs[i].startsWith(commonPrefix))
{
break;
}
if(i==strs.length-1)
{
isContinue=false;
}
}
if(isContinue)commonPrefix=commonPrefix.substring(0, commonPrefix.length()-1);
}
return commonPrefix;
}
}