Problem Statement | |||||||||||||
You are given an int k and a int[] numbers containing exactly N elements. Choose exactly k distinct integers between 0 and N-1, inclusive, and arrange them in ascending order. The difference between each pair of consecutive elements in this sequence must be less than or equal to maxDist. Each element in this sequence represents a zero-based index into the int[] numbers. Multiply the corresponding elements of numbers together to obtain a product. Return the maximal possible product you can get. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | numbers will contain between 1 and 50 elements, inclusive. | ||||||||||||
- | Each element of numbers will be between -50 and 50, inclusive. | ||||||||||||
- | k will be between 1 and 10, inclusive. | ||||||||||||
- | k will be less than or equal to the number of elements in numbers. | ||||||||||||
- | maxDist will be between 1 and 50, inclusive. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
|