public String longestCommonPrefix(String[] strs) {
    if (strs == null || strs.length == 0)
      return "";
    int minL = Integer.MAX_VALUE;
    for (String str : strs) {
      minL = Math.min(minL, str.length());
    }
    StringBuilder result = new StringBuilder();
    for (int i = 0; i < minL; i++) {
      char cur = strs[0].charAt(i);
      for (String str : strs) {
        if (str.charAt(i) != cur) {
          return result.toString();
        }
      }
      result.append(cur);
    }
    return result.toString();
  }