string Solution::longestCommonPrefix(vector &A) {

string ans="";

sort(A.begin(),A.end());

int n=A.size();

string s=A[n-1];

```
for(int j=0;j<A[0].size();j++)
{
if(A[0][j]==A[n-1][j])
ans+=A[n-1][j];
else
break;
}
return ans;
}
```