Problem Statement | |||||||||||||
We have a sorting machine that works on a list of distinct numbers. This machine only has one instruction named MOVE that takes one element of the list as a parameter. The MOVE instruction removes the element from the list and then appends it to the end of the remaining list. For example, the sequence {19,7,8,25} can be sorted in ascending order using 2 instructions: You will be given a int[] a containing a list of distinct numbers. Return the minimum number of instructions required to sort the list in ascending order. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
| - | a will have between 1 and 50 elements, inclusive. | ||||||||||||
| - | Each element of a will be between -1000 and 1000, inclusive. | ||||||||||||
| - | All elements of a will be distinct. | ||||||||||||
Examples | |||||||||||||
| 0) | |||||||||||||
| |||||||||||||
| 1) | |||||||||||||
| |||||||||||||
| 2) | |||||||||||||
| |||||||||||||
| 3) | |||||||||||||
| |||||||||||||
| 4) | |||||||||||||
| |||||||||||||
| 5) | |||||||||||||
| |||||||||||||