public class Solution
{
public bool IsAlienSorted(string[] words, string order)
{
string HumanDic = "abcdefghijklmnopqrstuvwxyz";
for (int i = ; i < words.Length; i++)
{
var AlienWord = words[i];
var HumanWord = "";
for (int j = ; 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 = ; i < words.Length; i++)
{
if (words[i] != OrderedWords[i])
{
return false;
}
}
return true;
}
}

leetcode953的更多相关文章

  1. [Swift]LeetCode953. 验证外星语词典 | Verifying an Alien Dictionary

    In an alien language, surprisingly they also use english lowercase letters, but possibly in a differ ...

  2. Leetcode953. Verifying an Alien Dictionary验证外星语词典

    某种外星语也使用英文小写字母,但可能顺序 order 不同.字母表的顺序(order)是一些小写字母的排列. 给定一组用外星语书写的单词 words,以及其字母表的顺序 order,只有当给定的单词在 ...

随机推荐

  1. bitset与取数凑数类问题

    bitset是C++中的一个东西,定义在头文件#include<bitset>里 所以可以使用#include<bitset>解决取数类的问题https://www.nowco ...

  2. net web service 参数类型

    因为Web Services的执行是建立在XML架构之上的,所以它能够支持丰富的数据类型. 下表列出了使用SOAP协议时Web Services支持的数据类型:  类 型 含 义 基础类型 也即标准基 ...

  3. Centos安装git2.2.1

    由于Centos6.5使用yum -y install git 安装的git版本是 git --versiongit version 1.7.1 想要升级到2.2.1: ># yum remov ...

  4. web.xml中context-param详解

    <context-param> <param-name>contextConfigLocation</param-name> <param-value> ...

  5. 为什么要用MQ

    现在公司系统在做微服务化,很多人在设计服务间通信时都会想到用MQ,然而有些人居然说不清楚为啥要用MQ? 其实用它主要是两点考虑: 1.应用解耦:两个服务间通过MQ通信,可以不用完全知道对方的存在,实现 ...

  6. hdu 4651 Partition && hdu 4658 Integer Partition——拆分数与五边形定理

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=4651 参考:https://blog.csdn.net/u013007900/article/detail ...

  7. bzoj1072排列

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1072 好像是这方面的裸题. 整除k 要想转移需要记录下 达到模k所有余数 的方案数. 为了生 ...

  8. vuex基本熟悉与使用

    vuex的入门与使用讲解 官网:https://vuex.vuejs.org/zh/guide/state.html 定义:Vuex 是一个专为 Vue.js 应用程序开发的状态管理模式.它采用集中式 ...

  9. ASP.NET 实现伪静态网页方法

    方法一:利用Httphandler实现URL重写(伪URL及伪静态) 我们有时候会见到这样的地址:“http://www.huoho.com/show-12-34.html”,你或许认为在站点服务器根 ...

  10. string截断

    public static string GetFirstString(string stringToSub, int length)         {            Regex regex ...