2019-11-10 LeetCode in Rust LeetCode 1004. Max Consecutive Ones III Problem Statement impl Solution { pub fn longest_ones(a: Vec<i32>, k: i32) -> i32 { let (mut ans, mut zeros, mut sum) = (0, 0, 0); let mut i = 0; for j in 0..a.len() { if a[j] == 0 { zeros += 1; } while zeros > k { if a[i] == 0 { zeros -= 1; } i += 1; } ans = std::cmp::max(ans, j - i + 1); } return ans as i32; }} Newer LeetCode 935. Knight Dialer Older LeetCode 1008. Construct Binary Search Tree from Preorder Traversal