please anyone help me out
class Solution {
public:
string longestCommonPrefix(vector& strs) {
string ans=strs[0];
if(strs.size()==0)
{
string s="";
return s;
}
for(int i=0;i<strs.size();i++)
{
string temp="";
string cmp=strs[i];
for(int j=0;j<min(ans.length(),cmp.length());j++)
{
if(ans[j]==cmp[j])
{
temp+=ans[j];
}
else
{
break;
}
}
ans=temp;
}
return ans;
}
};
Line 924: Char 9: runtime error: reference binding to null pointer of type ‘std::__cxx11::basic_string<char, std::char_traits, std::allocator >’ (stl_vector.h)this error i am getting…
