485. Max Consecutive Ones Easy

@problem@discussion
#Array



1/**
2 * [485] Max Consecutive Ones
3 *
4 * Given a binary array nums, return the maximum number of consecutive 1's in the array.
5 *  
6 * Example 1:
7 * 
8 * Input: nums = [1,1,0,1,1,1]
9 * Output: 3
10 * Explanation: The first two digits or the last three digits are consecutive 1s. The maximum number of consecutive 1s is 3.
11 * 
12 * Example 2:
13 * 
14 * Input: nums = [1,0,1,1,0,1]
15 * Output: 2
16 * 
17 *  
18 * Constraints:
19 * 
20 * 	1 <= nums.length <= 10^5
21 * 	nums[i] is either 0 or 1.
22 * 
23 */
24pub struct Solution {}
25
26// problem: https://leetcode.com/problems/max-consecutive-ones/
27// discuss: https://leetcode.com/problems/max-consecutive-ones/discuss/?currentPage=1&orderBy=most_votes&query=
28
29// submission codes start here
30
31impl Solution {
32    pub fn find_max_consecutive_ones(nums: Vec<i32>) -> i32 {
33        0
34    }
35}
36
37// submission codes end
38
39#[cfg(test)]
40mod tests {
41    use super::*;
42
43    #[test]
44    fn test_485() {
45    }
46}
47


Back
© 2025 bowen.ge All Rights Reserved.