freeCodeCamp:Missing letters
从传递进来的字母序列中找到缺失的字母并返回它。
如果所有字母都在序列中,返回 undefined。
function fearNotLetter(str) {
var arr = str.split("");
var newArr = [];
var start = str.charCodeAt(0);
var end = str.charAt(str.length - 1).charCodeAt(0);
for (var i = start; i < end+1; i++) {
var item = String.fromCharCode(i);
if ( arr[0] !== item ) {
newArr.push(item);
}else {
arr.shift();
}
}
if (newArr.length === 0) {
return undefined;
}else {
return newArr.join("");
}
}
fearNotLetter("abce");
freeCodeCamp:Missing letters的更多相关文章
- FCC-学习笔记 Missing letters
FCC-学习笔记 Missing letters 1>最近在学习和练习FCC的题目.这个真的比较的好,推荐给大家. 2>中文版的地址:https://www.freecodecamp.c ...
- Missing letters
function fearNotLetter(str) { //return str; var arr = str.split(''); var temp = []; var start = str. ...
- FreeCodeCamp 中级算法(个人向)
freecodecamp 中级算法地址戳这里 Sum All Numbers in a Range 我们会传递给你一个包含两个数字的数组.返回这两个数字和它们之间所有数字的和. function su ...
- Missing letters-freecodecamp算法题目
Missing letters 1.要求 从传递进来的字母序列中找到缺失的字母并返回它. 如果所有字母都在序列中,返回 undefined. 2.思路 设定缺失变量miss 在for循环遍历字符串的各 ...
- 2076 Problem F Quick Brown Fox
题目描述 A pangram is a phrase that includes at least one occurrence of each of the 26 letters, ‘a’. . . ...
- Codeforces Round #372 (Div. 2) B
Description ZS the Coder loves to read the dictionary. He thinks that a word is nice if there exists ...
- Codeforces Round #372 (Div. 2) A B C 水 暴力/模拟 构造
A. Crazy Computer time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- Codeforces 716B Complete the Word【模拟】 (Codeforces Round #372 (Div. 2))
B. Complete the Word time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- Complete the Word CodeForces - 716B
ZS the Coder loves to read the dictionary. He thinks that a word is nice if there exists asubstring ...
随机推荐
- yum update Transaction Check Error
update系统时,发现其中一台server居然提示: Transaction Check Error:file /usr/lib/perl5/5.8.8/CGI.pm from install of ...
- ps:探索按钮按起落下的技巧
(从死了一次又一次终于挂掉的百度空间中抢救出来的,发表日期 2014-07-10) 先上图: 那个看上去想按下去的,那个看上去像自然地呢? 显而易见: 第一像按下去的,第二个像自然地. 原因: 渐变: ...
- 安装配置tomcat环境
安装配置tomcat环境 #所需要软件包 apache-tomcat-7.0.65.tar.gz jdk-7u80-linux-x64.gz #建立 个专用账户 usradd tomcat ...
- Vehicle’s communication protocol
http://www.crecorder.com/techInfo/commuProtocols.jsp COMMUNICATION PROTOCOLS A “communication protoc ...
- UIImage imageNamed 与 imageWithContentsOfFile的差别
[UIImage imageNamed:]仅仅适合与UI界面中的贴图的读取,较大的资源文件应该尽量避免使用 用UIImage载入本地图像最经常使用的是以下三种: 1.用imageNamed方法 [UI ...
- javascript删除数组里的对象
Array.prototype.del = function(value) { //删除数组中指定的元素,返回新数组 function hasValue(array, value) { for(var ...
- UVA 12906 Maximum Score 排列组合
Maximum Score Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/vie ...
- Redis_字典
阅读本文之前要了解的两件事情,第一,Redis是一种Key-Value数据库,第二,字典是一种保存键值对的抽象数据结构.所以不难猜出字典在Redis中应用一定很广泛,实际上,Redis数据库的底层实现 ...
- Android-Chat-Widget
Original: https://github.com/ijarobot/Android-Chat-Widget Backup: https://github.com/eltld/Android-C ...
- TOJ3651确定比赛名次
确定比赛名次 Time Limit(Common/Java):1000MS/3000MS Memory Limit:65536KByte Total Submit: 23 ...