<awangdev>14. Longest Common Prefix_1.java
public String longestCommonPrefix(String[] strs) {
        if (strs == null || strs.length == 0) {
            return "";
        }
        
        Arrays.sort(strs);
        String head = strs[0];
        String tail = strs[strs.length - 1];
        
        int size = head.length() < tail.length() ? head.length() : tail.length();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < size; i++) {
            if (head.charAt(i) != tail.charAt(i)) {
                break;
            }
            sb.append(head.charAt(i));
        }
        return sb.toString();
    }
public String var_0 ( String [ ] var_2 ) {
  if ( var_2 == null || var_2 . length == 0 ) {
    return "" ;
  }
  Arrays . sort ( var_2 ) ;
  String var_9 = var_2 [ 0 ] ;
  String var_11 = var_2 [ var_2 . length - 1 ] ;
  int var_12 = var_9 . length ( ) < var_11 . length ( ) ? var_9 . length ( ) : var_11 . length ( ) ;
  StringBuffer var_14 = new StringBuffer ( ) ;
  for ( int var_15 = 0 ;
  var_15 < var_12 ;
  var_15 ++ ) {
    if ( var_9 . charAt ( var_15 ) != var_11 . charAt ( var_15 ) ) {
      break ;
    }
    var_14 . append ( var_9 . charAt ( var_15 ) ) ;
  }
  return var_14 . toString ( ) ;
}
