Facebook Pixel

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

Invest in Yourself
Your new job is waiting. 83% of people that complete the program get a job offer. Unlock unlimited access to all content and features.
Go Pro
Favorite (idle)