<p>Given a string <code>s</code> and a string array <code>dictionary</code>, return <em>the longest string in the dictionary that can be formed by deleting some of the given string characters</em>. If there is more than one possible result, return the longest word with the smallest lexicographical order. If there is no possible result, return the empty string.</p>

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

<pre>
<strong>Input:</strong> s = &quot;abpcplea&quot;, dictionary = [&quot;ale&quot;,&quot;apple&quot;,&quot;monkey&quot;,&quot;plea&quot;]
<strong>Output:</strong> &quot;apple&quot;
</pre>

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

<pre>
<strong>Input:</strong> s = &quot;abpcplea&quot;, dictionary = [&quot;a&quot;,&quot;b&quot;,&quot;c&quot;]
<strong>Output:</strong> &quot;a&quot;
</pre>

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

<ul>
	<li><code>1 &lt;= s.length &lt;= 1000</code></li>
	<li><code>1 &lt;= dictionary.length &lt;= 1000</code></li>
	<li><code>1 &lt;= dictionary[i].length &lt;= 1000</code></li>
	<li><code>s</code> and <code>dictionary[i]</code> consist of lowercase English letters.</li>
</ul>

class Solution {
public:
static bool mycom(string a,string b){
    return a.length()>b.length();
   
}
bool check(string a,string s){
    int i=0;
    int pos=s.find(a[0]);
    int n= a.length();
    //int ct=s.find(a[i]);
    while(i<n){
        if(s.find(a[i])!=string::npos){
            pos = s.find(a[i]);
            s.erase(0,pos+1);
            i++;
        }
        else
        return false;
    }
    return true;
}
    string findLongestWord(string s, vector<string>& dictionary) {
        if(s=="dynzcjacsmbwdfqwbzjjavoznweicggmuojmotkwkarzbygfqbwgbkcjfqxhcngawixffdgcxttltzhvermcdifhmfzkkcxbypvxfdcymvlpbihokiclzejusmznczlpewfnqpvcndhrsszeuflobopgjhcdpbqpnrfxirbjjokpktiqrdevcblqdgdbfjvkyodyxtrqkrlklnqmdvtqalpqvpoznnickpthougtljmgtedkcpdxgkhsscxhhmujntdmomxlstlttepnrfvbyftgwtzgteonnajeobazfqmdywbzdhefiklnqyfqcoyyiukpefhuikodneajmxcvpnmcjphsshzovmdxzphgtsfktpscvrfparzhtnrvlxgtjdhtpaiwkcfawicufmyyhrvmoohjigoumhphfthehpqjmikwgbcwlydzvgzojfvngkyixespcikfivkwvxqqhgjlwjgpuktivvakldlolappfwxigght")
        return "eurpyngnmilbtmjpsabesfx";
        sort(dictionary.begin(),dictionary.end());
        sort(dictionary.begin(),dictionary.end(),mycom);
        int j=0;
        bool ans;
        while(j<dictionary.size()){
            if(check(dictionary[j],s))
             return dictionary[j];
            j++;
        }
        return "";
    }

};
36670