Given a string s formed by digits ('0' - '9') and '#' . We want to map s to English lowercase characters as follows:
Characters ('a' to 'i') are represented by ('1' to '9') respectively.
Characters ('j' to 'z') are represented by ('10#' to '26#') respectively.
Return the string formed after mapping.
It's guaranteed that a unique mapping will always exist.
Example 1:
Input: s = "10#11#12"
Output: "jkab"
Explanation: "j" -> "10#" , "k" -> "11#" , "a" -> "1" , "b" -> "2".
Example 2:
Input: s = "1326#"
Output: "acz"
Example 3:
Input: s = "25#"
Output: "y"
var freqAlphabets = function(s) {
const map = { "1":"a", "2":"b", "3":"c", "4":"d", "5":"e",
"6":"f", "7":"g", "8":"h", "9":"i", "10":"j",
"11":"k", "12":"l", "13":"m", "14":"n", "15":"o",
"16":"p", "17":"q", "18":"r", "19":"s", "20":"t",
"21":"u", "22":"v", "23":"w", "24":"x", "25":"y",
"26":"z" };
let result = '';
for (let i = 0; i < s.length; ++i) {
result += map[s[i + 2] === '#' ? (i += 2, s[i - 2] + s[i - 1]) : s[i]];
}
return result;
};
<<: Day 27 -- Rails 实作 Rails-i18n语言选项在Bootstrap4 导览列
>>: HERE API Example - 显示 GeoJSON Data
过去我面试了不少公司的软件工程师职位,涵盖前端、後端,所以今天以Java相关职缺中常考的面试考题作为...
Abstract 前述章节以叙述过Spring Component注解的原理与运用,Spring核心...
前言 差不多要开始写专案了,今天要来看一下我们专案的目录结构,也会提到一些特别的档案和目录,包括之前...
有意义的讨论 层层拆解,找到歧异点 讨论过程里面,我们通常容易跳到结论做为起点,而我们通常也会先看到...
一二三元 什麽叫做三元运算子?有三元运算子那有没有一元和二元运算子? 三元运算子就是运算元有三个的运...