Amazon Online Assessment (OA) - Load Balancer

Given an array containing only positive integers, determine if you can select two integers from the array that divide the array into three pieces such that the sum of the elements in all pieces is equal.

Examples

Example 1:

Input: [2, 4, 5, 3, 3, 9, 2, 2, 2]
Output: true
Explanation:

Choosing the numbers 5 and 9 divides the array into three pieces [2, 4], [3, 3], and [2, 2, 2]. The sum of the elements in each piece is 6.

Example 2:

Input: [1, 1, 1, 1]
Output: false

Try it yourself


Got a question?ย Ask the Teaching Assistantย anything you don't understand.

Still not clear? Ask in the Forum, ย Discordย orย Submitย the part you don't understand to our editors.

โ†
โ†‘TA ๐Ÿ‘จโ€๐Ÿซ