class Solution {
public:
string longestCommonPrefix(vector<string>& strs) {
int size = strs.size();
if (size == 0) {
return "";
}
vector<char> v(128, 0);
string s = "";
int maxNum = INT_MAX;
for (int i = 0; i < size; i++) {
maxNum = min(maxNum, int(strs[i].size()));
}
for (int j = 0; j < maxNum; j++) {
for (int i = 0; i < size; i++) {
v[int(strs[i][j] - '0')]++;
}
if (v[int(strs[0][j] - '0')] == size) {
s.push_back(strs[0][j]);
v[int(strs[0][j] - '0')] = 0;
} else {
return s;
}
}
return s;
}
};