【Leetcode_easy】953. Verifying an Alien Dictionary
problem
953. Verifying an Alien Dictionary
solution:
class Solution {
public:
bool isAlienSorted(vector<string>& words, string order) {
unordered_map<char, int> alien_order;
for(int i=; i<order.size(); i++)
{
alien_order[order[i]-'a'] = i;
}
for(auto &word:words)
{
for(auto &ch:word)
{
ch = alien_order[ch-'a'];
}
}
return is_sorted(words.begin(), words.end());
}
};
参考
1. Leetcode_easy_953. Verifying an Alien Dictionary;
2. dicuss;
完
【Leetcode_easy】953. Verifying an Alien Dictionary的更多相关文章
- 【leetcode】953. Verifying an Alien Dictionary
题目如下: In an alien language, surprisingly they also use english lowercase letters, but possibly in a ...
- 【LeetCode】953. Verifying an Alien Dictionary 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.c ...
- 953.Verifying an Alien Dictionary(Map)
In an alien language, surprisingly they also use english lowercase letters, but possibly in a differ ...
- LeetCode 953 Verifying an Alien Dictionary 解题报告
题目要求 In an alien language, surprisingly they also use english lowercase letters, but possibly in a d ...
- LeetCode 953. Verifying an Alien Dictionary
原题链接在这里:https://leetcode.com/problems/verifying-an-alien-dictionary/ 题目: In an alien language, surpr ...
- 【Leetcode_easy】720. Longest Word in Dictionary
problem 720. Longest Word in Dictionary 题意: solution1: BFS; class Solution { public: string longestW ...
- LeetCode 953. Verifying an Alien Dictionary (验证外星语词典)
题目标签:HashMap 题目给了我们一个 order 和 words array,让我们依照order 来判断 words array 是否排序. 利用hashmap 把order 存入 map, ...
- Verifying an Alien Dictionary
2019-11-24 22:11:30 953. Verifying an Alien Dictionary 问题描述: 问题求解: 这种问题有一种解法是建立新的排序和abc排序的映射,将这里的str ...
- LeetCode.953-验证外语字典顺序(Verifying an Alien Dictionary)
这是悦乐书的第364次更新,第392篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第226题(顺位题号是953).在外语中,令人惊讶的是,他们也使用英文小写字母,但可能使 ...
随机推荐
- Web API系列(四) 使用ActionFilterAttribute 记录 WebApi Action 请求和返回结果记录
转自:https://www.cnblogs.com/hnsongbiao/p/7039666.html 需要demo在github中下载: https://github.com/shan333cha ...
- 共享库的使用(.so)文件
1.共享库的概念 2.创建共享库命令 gcc -shared -fpci -o lib/libmath.so obj/mymath.o 具体加不加 fpci 这个要看平台支持吧支持:具体详情可以查阅 ...
- 笔记-读官方Git教程(2)~安装与配置
小书匠 版本管理 教程内容基本来自git官方教程,认真都了系列的文章,然后对一些重点的记录下来,做了简单的归纳并写上自己的思考. 1.安装 在基于 Debian 的发行版上,使用 apt-get安装 ...
- mysql in()后子查询优化
线上数据发现一条数据大量等待的现象,通过explain发现这个sql写法存在问题,这里简单记录一下. 业务场景是这样: 存在购物车和费用两张表,购物车数据是购买商品时生成,用于记录购买商品数据,同时购 ...
- 数据量与半监督与监督学习 Data amount and semi-supervised and supervised learning
机器学习工程师最熟悉的设置之一是访问大量数据,但需要适度的资源来注释它.处于困境的每个人最终都会经历逻辑步骤,当他们拥有有限的监督数据时会问自己该做什么,但很多未标记的数据,以及文献似乎都有一个现成的 ...
- http与https区别,get与post请求区别
引用:http://blog.csdn.net/m0_38099607/article/details/72864684 HTTP与HTTPS的区别 超文本传输协议HTTP协议被用于在Web浏览器和网 ...
- session设置存活时间的三种方式
在web容器中设置(此处以tomcat为例)在tomcat-5.0.28\conf\web.xml中设置,以下是tomcat 5.0中的默认配置: [html] view plain copy < ...
- HTMLPage测试js通过ajax调用
HTMLPage测试js通过ajax调用接口 <!DOCTYPE html> <html lang="en" xmlns="http://www.w3. ...
- lnmp新增https访问【转】
环境是使用lnmp一键安装包搭建的: 1 首先去这个网站下载证书:免费ssl证书 最终会得到两个文件 2:在/usr/local/nginx/conf创建cert目录把这两个文件放进去,这个地址后面有 ...
- Java static静态关键字 有啥用
#static有啥用 在Java语言中,static表示“静态”的意思,使用场景可以用来修饰成员变量和成员方法,当然也可以是静态代码块.static的主要作用在于创建独立于具体对象的域变量或者方法. ...