#include <climits>
#include <algorithm>
class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param strs string字符串vector 
     * @return string字符串
     */
    string longestCommonPrefix(vector<string>& strs) {
        // write code here
        if(strs.empty()) return "";
        int n = strs.size();
        if(n==1) return strs[0];
        string res = "";
        int min_len = INT_MAX;
        for(string str:strs){
            min_len = min(min_len,static_cast<int>(str.size()));
        }
        for(int i=0;i<min_len;i++){
            char ch_tm = strs[0][i];
            for(int j=1;j<n;j++){
                if(strs[j][i]!=ch_tm) return res;
            }
            res += ch_tm;
        }
        return res;

    }
};