javascript 编程题目

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 */

posted @ 2015-06-12 16:58  8832A45C866CDB7D  阅读(128)  评论(0编辑  收藏  举报