您的位置:首页 > Web前端 > JavaScript

javascript 编程题目

2015-06-12 16:58 726 查看
1.you need to find the length of the sequence in an array, between the first and the second occurance of a specified number. /* 你需要找到一个数组中 指定元素 第一次 出现和 第二次 出现中间的 长度。 */ For example, for a given array arr

[0, -3, 7, 4, 0, 3, 7, 9] Finding length between two 7s like

lengthOfSequence([0, -3, 7, 4, 0, 3, 7, 9], 7)
would return 5. /* 像这个数组,元素7之间的长度是5. */ For sake of simplicity, there will only be numbers (positive or negative) in the supplied array.

If there are less or more than two occurences of the number to searched for, return 0. /* 为了简便,数组元素只为数字(包括正负),如果指定元素出现频率大于或少于2次,那么返回 0 */
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: