easy
public String longestCommonPrefix(String[] strs) {
if (strs == null || strs.length == 0) {
return "";
}
StringBuffer buffer = new StringBuffer();
int i = 0;
while (true) {
char c;
if (strs[0].length() == i) {
break;
} else {
c = strs[0].charAt(i);
}
boolean same = true;
for (String s : strs) {
if (s.length() == i) {
same = false;
break;
}
if (c != s.charAt(i)) {
same = false;
break;
}
}
if (!same) {
break;
}
buffer.append(c);
i++;
}
return buffer.toString();
}