isSumArray

Category: Arrays
Author: Benson Limketkai
Book Chapter: 4.2
Problem: isSumArray
Write a static method isSumArray that accepts an array of integers and returns whether for every group of three
elements in the array, the first two elements sum up to the third. If the size of the array cannot be divided into groups
of three, then the array does not pass the test.
For example, given the following arrays:

     int[] array1 = { 1, 2, 3, 8, 7, 15, 9, 3, 12 };
     int[] array2 = { 1, 2, 3, 4, 5 };
     int[] array3 = { 6, 11, 2008 };
     int[] array4 = { -4, 7, 3, 8, -2, 6 };

Calling isSumArray will result in the following values:

     +--------------------+----------------+
     | Call               | Value Returned |
     +--------------------+----------------+
     | isSumArray(array1) | true           |
     | isSumArray(array2) | false          |
     | isSumArray(array3) | false          |
     | isSumArray(array4) | true           |
     +--------------------+----------------+

In the first array, for every group of three numbers (1-2-3, 8-7-15, and 9-3-12), the first two numbers add up to the third. The second array cannot be divided into groups of three. The third array can be divided, but the first two numbers do not add up to the third.