public String longestCommonPrefix(String[] strs) {
        if (strs.length == 0)
            return "";
        String prefix = strs[0];
        for (String s : strs) {
            int i = 0, j = 0;
            String temp = "";
            while (i < prefix.length() && j < s.length()) {
                if (prefix.charAt(i) == s.charAt(j)) {
                    temp += prefix.charAt(i);
                    ++i;
                    ++j;
                } else
                    break;
            }
            prefix = temp;
        }
        return prefix;
    }