Partition Array Into Three Parts With Equal Sum Problem

Partition Array Into Three Parts With Equal Sum Problem — ExecCode Easy DSA Practice

Solve the Partition Array Into Three Parts With Equal Sum problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given an array of integers arr, return true if we can partition the array into three non-empty parts with equal sums. Your task is to formally, we can partition the array if we can find indexes i + 1 < j with (arr[0] + arr[1] + . arr[i] == arr[i + 1] + arr[i + 2] + ... + arr[j - 1] == arr[j] + arr[j + 1] + ... + arr[arr.length - 1]). Return the required answer exactly as shown in the examples.

Examples

Input {"arr": [0, 2, 1, -6, 6, -7, 9, 1, 2, 0, 1]}; Output True. Input {"arr": [0, 2, 1, -6, 6, 7, 9, -1, 2, 0, 1]}; Output False

Constraints

3 <= arr.length <= 5 * 10^4 -10^4 <= arr[i] <= 10^4

Practice Partition Array Into Three Parts With Equal Sum free on ExecCode. Browse DSA problems, topic map, and placement guides.