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的更多相关文章

  1. 【leetcode】953. Verifying an Alien Dictionary

    题目如下: In an alien language, surprisingly they also use english lowercase letters, but possibly in a ...

  2. 【LeetCode】953. Verifying an Alien Dictionary 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.c ...

  3. 953.Verifying an Alien Dictionary(Map)

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

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

    题目要求 In an alien language, surprisingly they also use english lowercase letters, but possibly in a d ...

  5. LeetCode 953. Verifying an Alien Dictionary

    原题链接在这里:https://leetcode.com/problems/verifying-an-alien-dictionary/ 题目: In an alien language, surpr ...

  6. 【Leetcode_easy】720. Longest Word in Dictionary

    problem 720. Longest Word in Dictionary 题意: solution1: BFS; class Solution { public: string longestW ...

  7. LeetCode 953. Verifying an Alien Dictionary (验证外星语词典)

    题目标签:HashMap 题目给了我们一个 order 和 words array,让我们依照order 来判断 words array 是否排序. 利用hashmap 把order 存入 map, ...

  8. Verifying an Alien Dictionary

    2019-11-24 22:11:30 953. Verifying an Alien Dictionary 问题描述: 问题求解: 这种问题有一种解法是建立新的排序和abc排序的映射,将这里的str ...

  9. LeetCode.953-验证外语字典顺序(Verifying an Alien Dictionary)

    这是悦乐书的第364次更新,第392篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第226题(顺位题号是953).在外语中,令人惊讶的是,他们也使用英文小写字母,但可能使 ...

随机推荐

  1. js清空数组

    js-清空array数组 两种实现方式: 1.splice:删除元素并添加新元素,直接对数组进行修改,返回含有被删除元素的数组. arrayObject.splice(index,howmany,el ...

  2. 【洛谷P4245】 【模板】任意模数NTT

    三模数 NTT,感觉不是很难写 $?$ 代码借鉴的 https://www.cnblogs.com/Mychael/p/9297652.html code: #include <bits/std ...

  3. am335x system upgrade kernel gpio(九)

    1      Hardware Overview gpio interface,pin map: AM335X_I2C0_W_C----------------------MCASP0_AXR1 /* ...

  4. Codevs 1500 后缀排序(后缀数组)

    1500 后缀排序 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 大师 Master 题目描述 Description 天凯是MIT的新生.Prof. HandsomeG给了他一个 ...

  5. 2017.10.7 国庆清北 D7T2 第k大区间

    题目描述 定义一个长度为奇数的区间的值为其所包含的的元素的中位数. 现给出n个数,求将所有长度为奇数的区间的值排序后,第K大的值为多少. 输入输出格式 输入格式: 输入文件名为kth.in. 第一行两 ...

  6. UOJ426. 【集训队作业2018】石像 [状压DP,min_25筛]

    UOJ 思路 (以下思路是口胡,但正确性大概没有问题.) 刚学min_25筛的时候被麦老大劝来做这题? 结果发现这题是个垃圾二合一?? 简单推一下式子可以得到答案就是这个: \[ \sum_{T=1} ...

  7. 地区sql

    /*Navicat MySQL Data Transfer Source Server : localhostSource Server Version : 50136Source Host : lo ...

  8. win10系统中对本地端口进行简单分析

    突然有事情涉及到本地端口,对相关内容进行了了解,这部分知识应该偏向运维,有些不好理解,查起来也零零散散的,理解的可能也有误……只记录一部分东西 想要查看本地端口的情况,在cmd下使用 netstat ...

  9. C语言strncasecmp()函数:比较字符串的前n个字符

    定义 int strncasecmp(const char *s1, const char *s2, size_t n); 描述 strncasecmp()用来比较参数s1 和s2 字符串前n个字符, ...

  10. ACL终极详解