leetcode953

Posted AsenYang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了leetcode953相关的知识,希望对你有一定的参考价值。

public class Solution
    {
        public bool IsAlienSorted(string[] words, string order)
        {
            string HumanDic = "abcdefghijklmnopqrstuvwxyz";
            for (int i = 0; i < words.Length; i++)
            {
                var AlienWord = words[i];
                var HumanWord = "";
                for (int j = 0; j < AlienWord.Length; j++)
                {
                    var ch = AlienWord[j];
                    var position = order.IndexOf(ch);
                    var realch = HumanDic[position];
                    HumanWord += realch.ToString();
                }
                words[i] = HumanWord;
            }

            var OrderedWords = words.OrderBy(x => x).ToArray();
            for (int i = 0; i < words.Length; i++)
            {
                if (words[i] != OrderedWords[i])
                {
                    return false;
                }
            }
            return true;
        }
    }

 

以上是关于leetcode953的主要内容,如果未能解决你的问题,请参考以下文章

leetcode953

LeetCode953

[LeetCode] 953. Verifying an Alien Dictionary

[LeetCode] 953. Verifying an Alien Dictionary

LeetCode --- 953. Verifying an Alien Dictionary 解题报告

Leetcode 953. Verifying an Alien Dictionary