1 2 3 4 5 6 7 8 9 10 11 12 13 14
| class Solution { public boolean findSubarrays(int[] nums) { Set<Integer> sumSet = new HashSet<>(); for (int i = 0; i < nums.length - 1; i++) { int sum = nums[i] + nums[i + 1]; if (sumSet.contains(sum)) { return true; } sumSet.add(sum); }
return false; } }
|
References
2395. Find Subarrays With Equal Sum