public String longestCommonPrefix(String[] strs) {
        String prefix = "";
        if (strs == null || strs.length == 0) return prefix;
        for (int i = 0; i < strs[0].length(); ++i) {
            char ch = strs[0].charAt(i);
            for (String s : strs) {
                if (i > s.length() - 1 || ch != s.charAt(i)) return prefix;
            }
            prefix += ch;
        }
        return prefix;
    }