<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 divideAndSolve(vector<string>& str, int start, int end)  {
        if (start == end) return str[start];

        int mid = start + (end - start) / 2;
        string LCPofLeft = divideAndSolve(str, start, mid);
        string LCPofRight = divideAndSolve(str, mid + 1, end);

        int i = 0;
        while (i < min(LCPofLeft.size(), LCPofRight.size())) {
            if (LCPofLeft[i] != LCPofRight[i])
                break;
            i++;
        }

        return i == 0? "" : LCPofLeft.substr(0, i);
    }
    string longestCommonPrefix(vector<string>& strs) {
        return divideAndSolve(strs, 0, strs.size() - 1);
    }
};
// aa aab aabc
// 0        2

// aa aab  (0, 1)--> aa (0, 0) --> aa   --> aa
//               --> aab(1, 1) --> aab
// aabc     (2, 2)                      --> aabc
13400