<p>Given an array of strings <code>strs</code>, return <em>the length of the <strong>longest uncommon subsequence</strong> between them</em>. If the longest uncommon subsequence does not exist, return <code>-1</code>.</p>

<p>An <strong>uncommon subsequence</strong> between an array of strings is a string that is a <strong>subsequence of one string but not the others</strong>.</p>

<p>A <strong>subsequence</strong> of a string <code>s</code> is a string that can be obtained after deleting any number of characters from <code>s</code>.</p>

<ul>
	<li>For example, <code>&quot;abc&quot;</code> is a subsequence of <code>&quot;aebdc&quot;</code> because you can delete the underlined characters in <code>&quot;a<u>e</u>b<u>d</u>c&quot;</code> to get <code>&quot;abc&quot;</code>. Other subsequences of <code>&quot;aebdc&quot;</code> include <code>&quot;aebdc&quot;</code>, <code>&quot;aeb&quot;</code>, and <code>&quot;&quot;</code> (empty string).</li>
</ul>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre><strong>Input:</strong> strs = ["aba","cdc","eae"]
<strong>Output:</strong> 3
</pre><p><strong class="example">Example 2:</strong></p>
<pre><strong>Input:</strong> strs = ["aaa","aaa","aa"]
<strong>Output:</strong> -1
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>2 &lt;= strs.length &lt;= 50</code></li>
	<li><code>1 &lt;= strs[i].length &lt;= 10</code></li>
	<li><code>strs[i]</code> consists of lowercase English letters.</li>
</ul>

class Solution {
public:
    bool check_is_substr(vector<string>& strs, string s){
        int count=0;
        for (string t: strs){
            if (t.size() < s.size()){
                return true;
            }
            int left=0;
            bool possible=true;
            for (char a: s){
                while (left < t.size() && t[left] != a){
                    left++;
                }
                if (left == t.size()){
                    possible=false;
                    break;
                }
                left++;
            }
            if (possible) count++;
            if (count > 1 ) return false;
        }
        return true;
    }

    int findLUSlength(vector<string>& strs) {
        auto comp=[&](string a, string b){
            return a.size() > b.size();
        };
        sort(strs.begin(), strs.end(), comp);
        map<string, int> counts;
        for (string s: strs){
            if (counts.find(s) == counts.end()){
                counts[s]=1;
            }
            else {
                counts[s]++;
            }
        }
        int maxlength=strs[0].size();
        for (string s: strs){
            if (s.size() == maxlength && counts[s]==1){
                return s.size();
            }
            if (check_is_substr(strs, s)){
                cout << s << "\n";
                return s.size();
            }
        }
        return -1;
    }
};
13244