diff --git a/src/main/java/com/cool/ling_cha_mount/sliding_windows/Num1004.java b/src/main/java/com/cool/ling_cha_mount/sliding_windows/Num1004.java new file mode 100644 index 0000000..4f9a12e --- /dev/null +++ b/src/main/java/com/cool/ling_cha_mount/sliding_windows/Num1004.java @@ -0,0 +1,25 @@ +package com.cool.ling_cha_mount.sliding_windows; + +/** + * Created with IntelliJ IDEA. + * + * @Author: Cool + * @Date: 2024/10/25/17:40 + * @Description: 1004. 最大连续1的个数 III + * @Score 1656 + */ +public class Num1004 { + public int longestOnes(int[] nums, int k) { + int zNum=0; + int res=0; + int left=0; + for(int i=0;ik){ + zNum-=(nums[left++]^1); + } + res=Math.max(res,i-left+1); + } + return res; + } +}