FastPrepFind an Equal-Sum Split
Problems/Find an Equal-Sum Split

Find an Equal-Sum Split

Meta logoMeta● EasyINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Meta intern phone screen. The report asks for two contiguous parts with equal sums and a yes or no on whether it is possible. It does not give limits on the numbers. Our version is about 97% the same as the reported question.

You are given an integer array nums. Can you split it at one position into two nonempty parts with equal sums? Keep the elements in their original order, and include every element in exactly one part.

Return true when such a boundary exists. Otherwise, return false.

Function

canSplitEqualSum(nums: int[]) → boolean

Examples

Example 1

nums = [1,2,3,6]return = true

Split after the first three elements. The sums of [1,2,3] and [6] are both 6.

Example 2

nums = [1,2,4]return = false

Neither valid boundary gives equal left and right sums.

Example 3

nums = [0,0,0]return = true

Splitting after the first element gives two nonempty parts whose sums are both 0.

Example 4

nums = [2,-2,5,0,5]return = true

The contiguous parts [2,-2,5] and [0,5] both sum to 5.

Constraints

  • 2 <= nums.length <= 2 * 10^5.
  • -10^9 <= nums[i] <= 10^9.
  • Every prefix sum and the total sum fit in a signed 64-bit integer.
All Meta interview questionsSee Meta hiring insights
Saved
class Solution {
    public boolean canSplitEqualSum(int[] nums) {
        // write your code here
    }
}
Checking account…