Problem Statement | |||||||||||||
We are given a int[] sequence containing a sequence of numbers. In a single operation, we can either increment or decrement the value of a single element by 1. Determine the minimum number of operations we must perform before the sequence contains at least K distinct elements. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Notes | |||||||||||||
- | Note that we can create negative elements during the process. | ||||||||||||
Constraints | |||||||||||||
- | sequence will contain between 1 and 50 elements, inclusive. | ||||||||||||
- | Each element in sequence will be between 1 and 1000, inclusive. | ||||||||||||
- | K will be between 1 and the number of elements in sequence, inclusive. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
| |||||||||||||
5) | |||||||||||||
|