题解 | #草原牛群集合#
草原牛群集合
https://www.nowcoder.com/practice/6fc74519ff9c44288dbcec5db7345ded
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param nums int整型一维数组
* @param val int整型
* @return int整型
*/
function remove_cows( nums , val ) {
// write code here
let count = 0;
for (let i = 0; i < nums.length; ++i)
{
if (nums[i] != val)
++count;
}
return count;
}
module.exports = {
remove_cows : remove_cows
};
- 题目考察的知识点:数组的遍历
- 题目解答方法的文字分析:遍历数组(目前这题程序没有检验返回的数组
- 本题解析所用的编程语言:js
查看14道真题和解析