Problem Statement |
| | You are given a int[] numbers and an int K. Let A be the sum of all values in numbers divisible by K, and let B be the sum of all values not visible by K. Return the absolute value of the difference between A and B. |
| |
Definition |
| | | Class: | ManyNumbers | | Method: | getSums | | Parameters: | int[], int | | Returns: | int | | Method signature: | int getSums(int[] numbers, int K) | | (be sure your method is public) |
|
| |
|
| |
Constraints |
| - | numbers will contain between 0 and 50 elements, inclusive. |
| - | Each element in numbers will be between 0 and 1000, inclusive. |
| - | K will be between 2 and 100, inclusive. |
| |
Examples |
| 0) | |
| | | Returns: 2 | | The sum of the values that are divisible by 3 is 3+6 = 9. The sum of the values not divisible by 3 is 2+4+5 = 11. |
|
|
| 1) | |
| | |
| 2) | |
| | |