We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
给定一个二进制数组, 计算其中最大连续1的个数。
用一个变量 count 计数,用一个变量 res 记录结果
count
res
/** * @param {number[]} nums * @return {number} */ var findMaxConsecutiveOnes = function(nums) { let count = 0, res = 0 for (const num of nums) { if (num === 1) { count++ } else { count = 0 } res = Math.max(res, count) } return res };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
题目剖析
解题思路
用一个变量
count
计数,用一个变量res
记录结果示例代码
The text was updated successfully, but these errors were encountered: