class Solution {
public:
string longestCommonPrefix(vector<string>& strs) {
int N = strs.size();
string ans = "";
if(N == 0) return ans;
int loc = 0;
while(true){
if(loc >= strs[0].size()) return ans;
char c = strs[0][loc];
for(int i=1;i<N;i++){
if(loc >= strs[i].size() || c != strs[i][loc]) return ans;
}
ans += c;
loc++;
}
return ans;
}
};