滑动窗口

滑动窗口_第1张图片

    public int[][] findContinuousSequence(int target) {
        List list = new ArrayList<>();
        for(int l = 1,r = 1,sum = 0;rtarget){
                sum-=l++;
            }
            if(sum==target){
                int[] temp = new int[r-l+1];
                for(int i = 0; i < temp.length; i++){
                     temp[i] = l + i;
                }
                list.add(temp);
            }
        }
        int[][] res = new int[list.size()][];
        for (int i = 0; i < res.length; i++) {
            res[i] = list.get(i);
        }
        return res;
        
    }

 

你可能感兴趣的:(滑动窗口)