Bootcamps
Masterclasses
Menu
Courses
Account
Login / Sign Up

Equal Sum Subarrays

Easy Acceptance 50% Points 20

Given an array of integers arr, return true if it is possible to split it in two subarrays (without reordering the elements), such that the sum of the two subarrays are equal. If it is not possible then return false.

Examples
Example 1

Example 1

Input: arr = [1, 2, 3, 4, 5, 5]

Output: true

Explanation: In the above example, we can divide the array into two subarrays with equal sum. The two subarrays are: [1, 2, 3, 4] and [5, 5]. The sum of both the subarrays are 10. Hence, the answer is true.

Example 2

Example 2

Input: arr = [4, 3, 2, 1]

Output: false

Explanation: In the above example, we cannot divide the array into two subarrays with equal sum. Hence, the answer is false.

Constraints
  • 1<=arr.size()<=10^5
  • 1<=arr[i]<=10^6
Topics
Queue
Companies
Meta
Added 18 Aug 2025 50% acceptance
Ln 1, Col 1Sign in to save your code
1 2 3 4 5 5
True