Can anyone help finding error!


#1

string Solution::longestCommonPrefix(vector &A)
{
int i,j=0;
int flag=0;
string s,k;
s="";

// int j=0;
for(i=0;i<A[0].size();i++)
{
k=A[0][i];
for(j=0;j<A[0].size();j++)
{
// count=0;
if( A[j][i]!=k || i>A[j].size() )
{
flag=1;
break;
}

  }
  if(flag==1)
  {
      break;
      return s;
  }
  s=s+k;
  
}

}