public String longestCommonPrefix(String[] strs) {
        int count = strs.length;
        if (strs.length == 0){
            return "";
        }
        String shortest = strs[0];
        for (int i = 0; i < count; i++){
            if (shortest.length() > strs[i].length()){
                shortest = strs[i];
            }
        }
        int len = shortest.length();
        int index = 0;
        for (int i = len; i > 0; i--){
            boolean common = true;
            for (int j = 0; j < count; j++){
                if (shortest.substring(0, i).compareTo(strs[j].substring(0, i)) != 0){
                    common = false;
                    break;
                }
            }
            if (common == true){
                index = i;
                break;
            }
        }
        if (index == 0){
            return "";
        }
        else {
            return shortest.substring(0, index);
        }
    }