赞
踩
题目:
分析:
代码:
- class Solution {
- public int longestOnes(int[] nums, int k) {
- int left = 0;
- int right = 0;
- int count = 0;
- int len = 0;
- while (right < nums.length) {
- if (nums[right] == 0)
- count++;
- while (count > k) {
- if (nums[left] == 0)
- count--;
- left++;
- }
- len = Math.max(len, right - left + 1);
- right++;
- }
- return len;
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。