subject

An array of integers is almost sorted if at most one element can be deleted from it to make it perfectly sorted, ascending. 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 of n unique integers, determine the minimum number of elements to remove so it becomes almost sorted. Example
arr = [3, 4, 2, 5, 1]
Remove 2 to get arr' = [3, 4, 5, 1] or remove 1 to get arr' = [3, 4, 2, 5), both of which are almost sorted. The minimum number of elements that must be removed in this case is 1.
Function Description
Complete the function
minDeletions in the editor below. minDeletions has the following parameter(s): int arr[n): an unsorted array of integers
Returns:
int: the minimum number of items that must be deleted to create an almost sorted array
Write in Python

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 23:00
In a file-oriented information system, a work file stores relatively permanent data about an entity is created and saved for backup and recovery purposes stores records that contain day-to-day business and operational data is a temporary file created by an information system for a single task
Answers: 1
question
Computers and Technology, 22.06.2019 06:50
Type the correct answer in the box. spell all words correctly. which view of report creation allows you to customize the report before the database program creates it? creating a report in allows you to customize the report before the database program creates it. pl asap
Answers: 1
question
Computers and Technology, 22.06.2019 18:30
Which cultural aspect does this type of song best portray? a german polka dance
Answers: 1
question
Computers and Technology, 22.06.2019 21:30
How do you take a green screen out of the video while editing?
Answers: 2
You know the right answer?
An array of integers is almost sorted if at most one element can be deleted from it to make it perfe...
Questions
question
Mathematics, 12.12.2020 16:50
question
Business, 12.12.2020 16:50
question
Mathematics, 12.12.2020 16:50
question
English, 12.12.2020 16:50