Ratiorg got statues
of different sizes as a present from CodeMaster for his birthday, each statue having an non-negative integer size. Since he likes to make things perfect, he wants to arrange them from smallest to largest so that each statue will be bigger than the previous one exactly by 1
. He may need some additional statues to be able to accomplish that. Help him figure out the minimum number of additional statues needed.
주어진 값 중에서 가장 큰 수의 값과 가장 작은 수의 값 사이에 없는 수의 개수를 구하여라.
Example
For statues = [6, 2, 3, 8]
, the output should bemakeArrayConsecutive2(statues) = 3
.
Ratiorg needs statues of sizes 4
, 5
and 7
.
Input: [5, 4, 6]
Expected Output: 0
Input: [6, 3]
Expected Output: 2
Code
int makeArrayConsecutive2(int[] statues) {
2
}
'알고리즘(CF)' 카테고리의 다른 글
8. matrixElementsSum (1) | 2017.06.08 |
---|---|
7. almostIncreasingSequence (1) | 2017.06.07 |
5. shapeArea (1) | 2017.06.07 |
4. adjacentElementsProduct (1) | 2017.06.07 |
3. checkPalindrome (1) | 2017.06.07 |