<p>Write a function to find the longest common prefix string amongst an array of strings.</p>

<p>If there is no common prefix, return an empty string <code>&quot;&quot;</code>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> strs = [&quot;flower&quot;,&quot;flow&quot;,&quot;flight&quot;]
<strong>Output:</strong> &quot;fl&quot;
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> strs = [&quot;dog&quot;,&quot;racecar&quot;,&quot;car&quot;]
<strong>Output:</strong> &quot;&quot;
<strong>Explanation:</strong> There is no common prefix among the input strings.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= strs.length &lt;= 200</code></li>
	<li><code>0 &lt;= strs[i].length &lt;= 200</code></li>
	<li><code>strs[i]</code> consists of only lowercase English letters.</li>
</ul>

class Solution {
public:
    string longestCommonPrefix(vector<string>& strs) {
       if(strs.size()==1)
       {
        return strs[0];
       }
        string s="";
       string s1=strs[0];
       string s2=strs[1];
       int min_length=min(s1.length(),s2.length());
       for(int i=0;i<min_length;i++)
       {
         if(s1[i]==s2[i])
         {
            s=s+s1[i];
         }
         else{
            break;
         }
       }
       if(strs.size()==2)
       {
        return s;
       }
       string s3=s;cout<<s;
       for(int i=2;i<strs.size();i++)
       {
       string s4=strs[i];
       min_length=min(s3.length(),s4.length());
        string s5="";
        // cout<<min_length;
       for(int j=0;j<min_length;j++)
       {
        if(s3[j]==s4[j])
        {
          s5=s5+s3[j];
          
        }
        else{
            break;
        }
       }
       s3=s5;

       }
       return s3;

    }
};
17500