Write a function to find the longest common prefix string amongst an array of strings.
class Solution { public: string longestCommonPrefix(vector<string> &strs) { // Start typing your C/C++ solution below // DO NOT write int main() function if(strs.size()==0)return ""; int minSize=strs[0].size(); for(int i=0;i<strs.size();i++){ if(minSize>strs[i].size()){ minSize=strs[i].size(); } } if(minSize==0)return ""; for(int j=0;j<minSize;j++){ char c=strs[0][j]; for(int i=1;i<strs.size();i++){ if(c!=strs[i][j]){ if(j==0)return ""; else return strs[0].substr(0,j); } } } return strs[0].substr(0,minSize); } };