Problem Statement
Create a class Coherency that contains a method starters that is given a
Definition
- Class:
- Coherency
- Method:
- starters
- Parameters:
- int[], int
- Returns:
- int
- Method signature:
- int starters(int[] collection, int maxJump)
- (be sure your method is public)
Constraints
- collection will contain between 1 and 50 elements, inclusive.
- Each element in collection will be between -1,000,000,000 and 1,000,000,000, inclusive.
- maxJump will be between 0 and 1,000,000,000, inclusive.
Examples
{8,1,1,1,1}
6
Returns: 0
However the values are arranged there must be a jump of 7.
{8,1,1,1,1}
7
Returns: 2
Any arrangement of these values has a maximum jump of 7. So we could start a satisfactory sequence with either a 1 or with the 8.
{6,1,11,5,7,1}
4
Returns: 2
(1,1,5,6,7,11) is a satisfactory sequence starting with 1. (11,7,6,5,1,1} is a satisfactory sequence starting with 11. There is no satisfactory sequence that starts with any of the other values, so there are 2 distinct possible starting values.
{1,5,5,9,10,11,12,12,12,16,17}
4
Returns: 3
{2,3,6,9,11,14,16,20,21}
4
Returns: 3
{1,2,3,4,5,6,7}
2
Returns: 7
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
1000000000
Returns: 1
{9,8,7,6,5,4,3,-2}
4
Returns: 0
{-6,-3,-1,0,0,4,8}
4
Returns: 2
{4,4,4,4,5,9}
4
Returns: 2
{1,2,3,6,8,9,10,14,18,22}
4
Returns: 4
{-1,-3,-3,-6,-7,-8,-12,-12,-13}
4
Returns: 6
{-1,-3,-3,-6,-7,-8,-12,-12,-13}
1000000
Returns: 7
{0,1000000,1000000,2000000,2000000,2000000,3000000,4000000,4000000,5000000,5000000,6000000,7000000,7000000,8000000,8000000,9000000,10000000,11000000,11000000}
1000000
Returns: 4
{-451000123,123456789,234567891,234567891,345678912,456789123,0,-123456789,-234567891,-345678912}
151222333
Returns: 2
{4}
0
Returns: 1
{0}
0
Returns: 1
{1,1,1,1,1,1,1,1,1,1,1,1,1,1}
0
Returns: 1
{1,1,1,1,1,1,1,1,6,6,6,6,6,6,6,6}
4
Returns: 0
{1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8}
1
Returns: 8