public String longestCommonPrefix(String[] strs) {

        //if the length is 0, return "". means nothing inside.
        if (strs.length == 0) {
            return "";
        }

        //int count = 0;
        //for loop the first string int the list, check if the rest string match the char in the same position
        for (int i = 0; i < strs[0].length(); i++) {
            //count++;
            char temp = strs[0].charAt(i);
            //loop all the string
            for (int j = 1; j < strs.length; j++) {
                //if find the shortest string, return
                //if the char at that position is not the same, return
                if (i >= strs[j].length() || strs[j].charAt(i) != temp) {
                    return strs[0].substring(0, i);
                }
            }
        }
        //otherwise, the first string is the shortest one, and match all. return the first string.
        return strs[0];
        //return strs[0].substring(0, count);
    }