java.lang.Object
g2301_2400.s2395_find_subarrays_with_equal_sum.Solution

public class Solution extends Object
2395 - Find Subarrays With Equal Sum.<p>Easy</p> <p>Given a <strong>0-indexed</strong> integer array <code>nums</code>, determine whether there exist <strong>two</strong> subarrays of length <code>2</code> with <strong>equal</strong> sum. Note that the two subarrays must begin at <strong>different</strong> indices.</p> <p>Return <code>true</code> <em>if these subarrays exist, and</em> <code>false</code> <em>otherwise.</em></p> <p>A <strong>subarray</strong> is a contiguous non-empty sequence of elements within an array.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> nums = [4,2,4]</p> <p><strong>Output:</strong> true</p> <p><strong>Explanation:</strong> The subarrays with elements [4,2] and [2,4] have the same sum of 6.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> nums = [1,2,3,4,5]</p> <p><strong>Output:</strong> false</p> <p><strong>Explanation:</strong> No two subarrays of size 2 have the same sum.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> nums = [0,0,0]</p> <p><strong>Output:</strong> true</p> <p><strong>Explanation:</strong> The subarrays [nums[0],nums[1]] and [nums[1],nums[2]] have the same sum of 0.</p> <p>Note that even though the subarrays have the same content, the two subarrays are considered different because they are in different positions in the original array.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>2 <= nums.length <= 1000</code></li> <li><code>-10<sup>9</sup> <= nums[i] <= 10<sup>9</sup></code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • findSubarrays

      public boolean findSubarrays(int[] nums)