Given a sequence of integers as an array, determine whether it is possible to obtain a strictly increasing sequence by removing no more than one element from the array.
제공된 배열의 일련번호에서 두개의 요소를 제거할 수 있다. 일련번호가 엄격하게 숫자가 증가하는지 확인하라
Example
For
sequence = [1, 3, 2, 1]
, the output should bealmostIncreasingSequence(sequence) = false
;There is no one element in this array that can be removed in order to get a strictly increasing sequence.
For
sequence = [1, 3, 2]
, the output should bealmostIncreasingSequence(sequence) = true
.You can remove
3
from the array to get the strictly increasing sequence[1, 2]
. Alternately, you can remove2
to get the strictly increasing sequence[1, 3]
.
boolean almostIncreasingSequence(int[] sequence) {
}
문제의 이해도 어려웠지만 해결은 더 어려웠다.
'알고리즘(CF)' 카테고리의 다른 글
9. allLongestStrings (1) | 2017.06.08 |
---|---|
8. matrixElementsSum (1) | 2017.06.08 |
6. make Array Consecutive2 (1) | 2017.06.07 |
5. shapeArea (1) | 2017.06.07 |
4. adjacentElementsProduct (1) | 2017.06.07 |