Write a function to find the longest common prefix string amongst an array of strings.
class Solution { public: string longestCommonPrefix(vector<string> &strs) { int lenOfstrs= strs.size(); if(!lenOfstrs)return ""; string Prefix=strs[0]; for(int i=1;i<lenOfstrs;i++) { if(Prefix.length()==0||strs[i].length()==0) return ""; int len=min(Prefix.length(),strs[i].length()); int j=0; for(;j<len;j++) { if(Prefix[j]!=strs[i][j]) break; } Prefix=Prefix.substr(0,j); } return Prefix; } };