All problems
0900EasyArrayHash Table

Two Neighbouring Pairs of Equal Load

Tracked in this browser only
Write code

Trains the technique from

LeetCode 2395Find Subarrays With Equal Sum

This is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.

Same function shape, different story and different numbers.

A conveyor holds readings nums.

Consider the pairs of neighbouring readings: the pair at position i is nums[i] together with nums[i + 1]. Two such pairs are different when they start at different positions, even if they hold the same readings.

Return true when two different neighbouring pairs have the same total.

Examples

Example 1

Input
nums = [14, 9, 5, 18, 6, 17]
Output
true

The neighbouring pairs total 23, 14, 23, 24 and 23, so the pair starting at position 0 and the one starting at position 2 match.

Example 2

Input
nums = [10, 20, 30, 40, 50]
Output
false

The totals are 30, 50, 70 and 90, all different.

Example 3

Input
nums = [3, 3, 3]
Output
true

Both pairs hold the same readings and so total the same, and they start at different positions, which is what makes them different pairs.

Constraints

  • 2 <= nums.length <= 1000
  • -10^9 <= nums[i] <= 10^9

The signature

The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.

Python
def find_subarrays(nums: list[int]) -> bool:
Java
public boolean findSubarrays(int[] nums)
September 7
Apply