Leetcode-953 Verifying an Alien Dictionary(验证外星语词典)
Posted Asurudo Jyo の 倉 庫
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Leetcode-953 Verifying an Alien Dictionary(验证外星语词典)相关的知识,希望对你有一定的参考价值。
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 };
以上是关于Leetcode-953 Verifying an Alien Dictionary(验证外星语词典)的主要内容,如果未能解决你的问题,请参考以下文章
LeetCode --- 953. Verifying an Alien Dictionary 解题报告
Leetcode 953. Verifying an Alien Dictionary
Leetcode-953 Verifying an Alien Dictionary(验证外星语词典)
leetcode 953. Verifying an Alien Dictionary & 949. Largest Time for Given Digits & 948. Bag