John has a list of integers first, and his task is to transform it so that it contains exactly the same elements as another list second (but not necessarily in the same order).
To achieve this goal, John will perform a number of operations in sequence. These are the three operations that can be performed on a list:
- Add some arbitrary integers to the list. The number of elements added must not be more than the size of the list before the operation.
- Delete some elements from the list. The number of elements deleted must not be more than half of the size of the list before the operation.
- Arbitrarily change some elements in the list. The number of elements changed must not be more than half of the size of the list.
You are given int[]s first and second. Return the minimum number of operations required to achieve John's goal.
|