1 string ooder;
 2 bool cmp(const string &a,const string &b)
 3 {
 4     for(int i = 0;i < min(a.size(),b.size());i ++)
 5     {
 6         if(a[i]!=b[i])
 7         {
 8             for(int j = 0;j < ooder.size();j ++)
 9             {
10                 if(ooder[j]==a[i])
11                     return 1;
12                 else if(ooder[j]==b[i])
13                     return 0;
14             }
15         }
16     }
17     return a.size()<b.size();
18 }
19 
20 class Solution
21 {
22     public:
23         bool isAlienSorted(vector<string>& words, string order)
24         {
25             vector<string> words2 = words;
26             ooder = order;
27             sort(words.begin(),words.end(),cmp);
28             for(int i = 0;i < words2.size();i ++)
29             {
30                 if(words[i]!=words2[i])
31                     return false;
32             }
33             return true;
34         }
35 };

 

相关文章:

  • 2021-08-03
  • 2021-10-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-13
猜你喜欢
  • 2021-10-19
  • 2021-12-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-28
相关资源
相似解决方案