← 返回 salesforce 的题目列表Minimum Removals to Make Array Almost Sorted
类型:online_judge
Given an array of n unique integers, an array is almost sorted if at most one element can be deleted to make it perfectly sorted in ascending order. For example, arrays [2, 1, 7], [13], [9,2] and [1, 5, 6] are almost sorted because they have 0 or 1 elements out of place. The arrays [4, 2, 1], [1, 2, 6, 4, 3] are not because they have more than one element out of place. Given an array, determine the minimum number of elements to remove so it becomes almost sorted.
Example
Input
5
1 3 2 4 5