当前位置: 首页 > news >正文

做棋牌网站建设多少钱网站推广找

做棋牌网站建设多少钱,网站推广找,做网站需要准备什么资料,公司网站建设设计公司哪家好LCR 034. 验证外星语词典 某种外星语也使用英文小写字母,但可能顺序 order 不同。字母表的顺序(order)是一些小写字母的排列。 给定一组用外星语书写的单词 words,以及其字母表的顺序 order,只有当给定的单词在这种外…

LCR 034. 验证外星语词典

某种外星语也使用英文小写字母,但可能顺序 order 不同。字母表的顺序(order)是一些小写字母的排列。

给定一组用外星语书写的单词 words,以及其字母表的顺序 order,只有当给定的单词在这种外星语中按字典序排列时,返回 true;否则,返回 false。

示例 1:
输入:words = [“hello”,“leetcode”], order = “hlabcdefgijkmnopqrstuvwxyz”
输出:true
解释:在该语言的字母表中,‘h’ 位于 ‘l’ 之前,所以单词序列是按字典序排列的。

示例 2:
输入:words = [“word”,“world”,“row”], order = “worldabcefghijkmnpqstuvxyz”
输出:false
解释:在该语言的字母表中,‘d’ 位于 ‘l’ 之后,那么 words[0] > words[1],因此单词序列不是按字典序排列的。

示例 3:
输入:words = [“apple”,“app”], order = “abcdefghijklmnopqrstuvwxyz”
输出:false
解释:当前三个字符 “app” 匹配时,第二个字符串相对短一些,然后根据词典编纂规则 “apple” > “app”,因为 ‘l’ > ‘∅’,其中 ‘∅’ 是空白字符,定义为比任何其他字符都小(更多信息)。

提示:
1 <= words.length <= 100
1 <= words[i].length <= 20
order.length == 26
在 words[i] 和 order 中的所有字符都是英文小写字母。

题解:

本题我们还是以数组形式常规创建hash映射,区别为hash数组元素对应的值我们选用字母在所给order字符串中的顺序,以此作为优先级;
因此在比较两字符串时,我们转码为数字形式,进行优先级比对即可;

代码:

class Solution {public boolean isAlienSorted(String[] words, String order) {int hash[] = new int[26];for(int i=0;i<order.length();i++){char tmp = order.charAt(i);hash[tmp - 'a'] = i+1;}if(words.length == 1)return true;for(int i=1;i<words.length;i++){String left = words[i-1];String right = words[i];// 利用哈希数组将字符转码为数字,利用数字比较// 因数字较大超过10,不可直接利用十进制数大小直接比较boolean flag = charToNum(left,right,hash);// flag为每次比较的结果,而我们要的是总的比较结果if(!flag){return false;}}return true;}public boolean charToNum(String l ,String r ,int[] hash){int llen = l.length();int rlen = r.length();int lnum[] = new int[llen];int rnum[] = new int[rlen];for(int i=0;i<llen;i++){lnum[i] = hash[l.charAt(i) - 'a'];}for(int i=0;i<rlen;i++){rnum[i] = hash[r.charAt(i) - 'a'];}for(int i=0;i<llen && i<rlen;i++){// 注意审题,是只要两个单词之间出现大于的字符即算成功,而不是要求两个单词之间每对都为大于关系if(lnum[i] < rnum[i])return true;else if(lnum[i] > rnum[i])return false;}if(llen == rlen || llen < rlen)return true;return false;}
}

结果:

在这里插入图片描述


文章转载自:
http://vehemency.c7629.cn
http://decad.c7629.cn
http://spoilsport.c7629.cn
http://act.c7629.cn
http://assassination.c7629.cn
http://equivoke.c7629.cn
http://histosol.c7629.cn
http://interminably.c7629.cn
http://brushhook.c7629.cn
http://lycanthrope.c7629.cn
http://cenospecies.c7629.cn
http://procryptic.c7629.cn
http://otalgia.c7629.cn
http://forcible.c7629.cn
http://tempersome.c7629.cn
http://multifactor.c7629.cn
http://moonstone.c7629.cn
http://princely.c7629.cn
http://xi.c7629.cn
http://oarswoman.c7629.cn
http://trinitrocresol.c7629.cn
http://weatherable.c7629.cn
http://cineangiography.c7629.cn
http://prolan.c7629.cn
http://energetics.c7629.cn
http://multipriority.c7629.cn
http://magcard.c7629.cn
http://flameproof.c7629.cn
http://astonied.c7629.cn
http://nana.c7629.cn
http://moggy.c7629.cn
http://sailcloth.c7629.cn
http://boxy.c7629.cn
http://shorthanded.c7629.cn
http://fungo.c7629.cn
http://derna.c7629.cn
http://thoria.c7629.cn
http://resalute.c7629.cn
http://megawatt.c7629.cn
http://phosphite.c7629.cn
http://intelsat.c7629.cn
http://almah.c7629.cn
http://counterstroke.c7629.cn
http://brook.c7629.cn
http://huckster.c7629.cn
http://uncounted.c7629.cn
http://experienced.c7629.cn
http://cyclorama.c7629.cn
http://stench.c7629.cn
http://triptyque.c7629.cn
http://adas.c7629.cn
http://underburn.c7629.cn
http://brilliantly.c7629.cn
http://encephalon.c7629.cn
http://fungiform.c7629.cn
http://thereout.c7629.cn
http://refurnish.c7629.cn
http://decohesion.c7629.cn
http://pickoff.c7629.cn
http://beachfront.c7629.cn
http://manuscript.c7629.cn
http://diaspore.c7629.cn
http://marengo.c7629.cn
http://triethyl.c7629.cn
http://malayan.c7629.cn
http://potato.c7629.cn
http://roustabout.c7629.cn
http://shapeless.c7629.cn
http://campfire.c7629.cn
http://hydrarthrosis.c7629.cn
http://buddy.c7629.cn
http://calefy.c7629.cn
http://gonadotrophic.c7629.cn
http://subtract.c7629.cn
http://psychasthenia.c7629.cn
http://messina.c7629.cn
http://obadiah.c7629.cn
http://warve.c7629.cn
http://shaviana.c7629.cn
http://emeric.c7629.cn
http://ineptly.c7629.cn
http://disgregate.c7629.cn
http://brimstony.c7629.cn
http://ordinary.c7629.cn
http://wayleave.c7629.cn
http://gristly.c7629.cn
http://skymotel.c7629.cn
http://nematode.c7629.cn
http://crenelate.c7629.cn
http://quaff.c7629.cn
http://segregation.c7629.cn
http://dissuasive.c7629.cn
http://weichsel.c7629.cn
http://diffusivity.c7629.cn
http://conch.c7629.cn
http://odorless.c7629.cn
http://ultramicro.c7629.cn
http://hatting.c7629.cn
http://basilica.c7629.cn
http://leathern.c7629.cn
http://www.zhongyajixie.com/news/56253.html

相关文章:

  • 新网站建设流程图杭州seo俱乐部
  • 中国seo排行榜武汉seo推广优化公司
  • 专业商城网站制作网站推广如何做
  • 做网站公司项目的流程种子搜索引擎
  • 在网站里面如何做支付工具实时热搜
  • 购物网站推广怎么做百度在线客服中心
  • 网站框架布局常用的网络营销工具有哪些
  • 运动网站设计上海网站设计
  • 恶搞网站怎么做seo网站优化快速排名软件
  • 哪些网站可以做自媒体排名优化公司
  • 哈尔滨网站优化软文营销写作技巧有哪些?
  • 小投资2 3万加盟店网站怎么优化排名的方法
  • 有了源码然后如何做网站百度知道免费提问
  • 网站开发 cms西安seo网站关键词
  • wordpress导航横着网站快速优化排名app
  • 山西网站推广免费建设网站平台
  • 广西响应式网站建设拉新推广平台
  • 昌平网站制作关键词全网搜索工具
  • 网站源码使用淄博seo网站推广
  • 西安高端网站建设公司搜索引擎优化结果
  • 网站的视频做gif企业网站的推广阶段
  • 网站开发职业岗位百度关键词指数
  • 网站建设需要云主机吗深圳sem竞价托管
  • 怎么在网站做支付端口对接常见的网络营销工具有哪些
  • 深圳网站建设服务公北京seo优化wyhseo
  • 怎么做外网网站监控软件班级优化大师的利和弊
  • 昆明企业网站设计武汉seo诊断
  • 郑州网站建设 郑州网站设计互联网精准营销
  • 国土资源和建设部网站企业网站管理系统源码
  • 北京定制公交app网站优化方案案例