• 首页
  • 粮食
  • 蔬菜
  • 果品
  • 水产
  • 酒水
  • 饮料
  • 茶叶
  • 畜禽
  • 食用油
  • 资讯
logo
  • 首页>
  • 水产 >
  • 正文

LeetCode 2325. Decode the Message

2023-05-03 08:52:51 来源:哔哩哔哩

You are given the strings keyand message, which represent a cipher key and a secret message, respectively. The steps to decode messageare as follows:

Use the first appearance of all 26 lowercase English letters in keyas the order of the substitution table.

Align the substitution table with the regular English alphabet.


【资料图】

Each letter in messageis then substituted using the table.

Spaces ' 'are transformed to themselves.

For example, given key = "happy boy"(actual key would have at least one instance of each letter in the alphabet), we have the partial substitution table of ('h' -> 'a', 'a' -> 'b', 'p' -> 'c', 'y' -> 'd', 'b' -> 'e', 'o' -> 'f').

Return the decoded message.

Example 1:

Input: key = "the quick brown fox jumps over the lazy dog", 

message = "vkbs bs t suepuv"

Output: "this is a secret"

Explanation: The diagram above shows the substitution table.It is obtained by taking the first appearance of each letter in "the quick brown fox jumps over the lazy dog".

Example 2:

Input: key = "eljuxhpwnyrdgtqkviszcfmabo", 

message = "zwx hnfx lqantp mnoeius ycgk vcnjrdb"

Output: "the five boxing wizards jump quickly"

Explanation: 

The diagram above shows the substitution table.It is obtained by taking the first appearance of each letter in "eljuxhpwnyrdgtqkviszcfmabo".

Constraints:

26 <= key.length <= 2000

keyconsists of lowercase English letters and ' '.

keycontains every letter in the English alphabet ('a'to 'z') at least once.

1 <= message.length <= 2000

messageconsists of lowercase English letters and ' '.

题目是easy题目,其实就是做一个映射,然后根据message 返回映射的信息即可;

用hashmap可以,也可以直接用数组;下面是代码:

Runtime: 7 ms, faster than 71.47% of Java online submissions for Decode the Message.

Memory Usage: 42.7 MB, less than 50.31% of Java online submissions for Decode the Message.

关键词:

    为您推荐

  • LeetCode 2325. Decode the Message

    水产2023-05-03
  • 再创历史!张之臻晋级马德里大师赛8强! 天天热讯

    水产2023-05-03
  • 重返美网!德约科维奇的机会来了,大满贯冠军数量有望再+1

    水产2023-05-03
  • 没业绩就别讲你有多累多冤多忙!-环球聚焦

    水产2023-05-03
  • 公输盘之攻械尽的之什么意思_公输盘之攻械尽 简讯

    水产2023-05-03
  • 定了!延长至2024年底!|世界报资讯

    水产2023-05-02
  • 亚硝酸盐作为一种食品添加剂具有哪些特点_亚硝酸盐作为食品添加剂具有什么作用 世界快播

    水产2023-05-02
  • 世界热头条丨生肖姓名学兔起名哪些字最好

    水产2023-05-02
  • 第六季党校公开课超燃来袭!

    水产2023-05-02
  • 观热点:PHP-web框架Laravel-队列(一)

    水产2023-05-02
  • 大家乐集团(00341.HK)盈喜:预计年度录得股东应占溢利1.05亿港元至1.15亿港元_天天微头条

    水产2023-05-02
  • 陕西航空专业怎么样省公办前十

    水产2023-05-02
  • 单位换算表大全图片 单位换算表|天天速看料

    水产2023-05-02
  • api是什么语言_api是什么

    水产2023-05-02
  • 每日观点:“丝路风华”青少年国际文化艺术节雁栖湖举办

    水产2023-05-02
  • 美媒:美国第一共和银行股票或被移出标普指数

    水产2023-05-02
  • 国际货币基金组织:亚太范围内 中国对全球经济增长的贡献排名第一

    水产2023-05-02
  • 凌晨官宣:离婚

    水产2023-05-02
  • 运动用品 多层次需求促创新

    水产2023-05-02
  • 高清图:广西最长跨海大桥全面进入上部结构施工阶段

    水产2023-05-02

果品

  • 北京2022年冬奥会、冬残奥会奖牌“同心”正式发布
  • 冬奥故事会丨一图了解冬奥会历届奖牌
  • 同心筑梦向未来——写在北京冬奥会开幕倒计时100天之际
  • 外交部:美国针对亚裔仇恨犯罪数字令人痛心

蔬菜

  • 说好“一梯一户”却成了“两梯两户”,买方能否解除合同?
  • 更高水平开放合作助力中国东盟经贸发展迎新机遇
  • 9被告人犯侵犯著作权罪被判刑罚
  • 玉渊谭天丨中美再通话,“建设性”很重要
  • 环球时报社评:中美经贸需要建设性对话
  • 俄媒:莫斯科扩大新冠感染新疗法试点范围
  • 冰雪之约 中国之邀 | 追赶的勇气
  • 中国第20批赴黎维和建筑工兵分队完成“VA-2”道路排水系统修缮任务
  • 中国常驻联合国代表团举办恢复联合国合法席位50周年图片展
  • 美专家认为三大原因导致美国供应链危机

Copyright   2015-2022 南方食品网 版权所有  备案号:粤ICP备18023326号-21   联系邮箱:855 729 8@qq.com