Problem Statement
Given a number N, your goal is to color the set of integers from 1 to N. The way you are allowed to color depends on the given sequence. Namely, if the difference (the absolute value of subtracting one from another) of two integers belongs to the sequence, then those numbers should be colored in different colors.
You task is, given a number N and a sequence, return the minimum number of colors you need to color the set of integers from 1 to N in the manner described above.
Definition
- Class:
- Color
- Method:
- min
- Parameters:
- int, int[]
- Returns:
- int
- Method signature:
- int min(int N, int[] sequence)
- (be sure your method is public)
Constraints
- N is between 1 and 10
- sequence contains between 1 and 9 elements
- each element of sequence is between 1 and 9
Examples
10
{1}Returns: 2
you can color odd numbers in one color and even numbers in another color10
{1,2,3,4,5,6,7,8,9}Returns: 10
all numbers should be colored in different colors10
{3,1}Returns: 2
you can color odd numbers in one color and even numbers in another color8
{1,2}Returns: 3