Given a binary array nums (containing only 0s and 1s), return the maximum number of consecutive 1s in the array.
For example, given [1, 1, 0, 1, 1, 1], the longest streak of consecutive 1s is 3 (the last three elements).
nums = [1, 1, 0, 1, 1, 1]3nums = [1, 0, 1, 1, 0, 1]2nums = [0, 0, 0]01 <= nums.length <= 10^5nums[i] is either 0 or 1Run your code to see results
Use Cmd+Enter to run