Fork me on GitHub

2395. 和相等的子数组[每日一题]

    public boolean findSubarrays(int[] nums) {
        Map<Integer,Integer> allSets = new HashMap<>();
        for(int i = 0; i < nums.length - 1; i++){
            int res= nums[i] + nums[i+1];
            if(allSets.containsKey(res)){
                return true;
            }
            allSets.put(res, allSets.getOrDefault(res,0)+1);
        }
        return false;
    }
}


这题没什么好说的 ,集合也可以,很简单
posted @ 2023-03-26 23:33  RickieRun  阅读(25)  评论(0)    收藏  举报
Live2D