# Shortest 11 Problem 100

## Transform

```Transform

You are given two arrays A and B of equal size N. Your goal is to make A identical to B with minimum number of transformations.
By identical we mean A[i] == B[i] for every i in N.
You are allowed to make transformations only on the array A and the transformations are:
- Increment an element in the array.
- Decrement an element in the array.
- Shift every element in A to the right for one place. (and move the rightest one to the first place)

You need to return the minimum number of performed transformations in order to make the arrays identical.

Example1:
A = {1, 3, 5}, B = {2, 1, 5}. The answer is 3. You need to increment A[0] and decrement A[1] twice.

Example2:
A = {1, 8}, B = {9, 1}. The answer is 2. You shift the array A and the array becomes A = {8, 1}, then you increment A[0].

Example3:
A = {1, 5, 10}, B = {5, 10, 1}. The answer is 2. You shift the array A twice.

Input parameters:
A - the first array that needs to be transformed.
B - the target array.

Constraints:
N - the size of the array will be between 1 and 50 inclusive.
E - each element in the array will be between 1 and 1000 invlusive.

Return value:
The minimum number of operations that needed to be performed.
Class Name:
Transform

Method signature:
public int minTransformations(int[] a, int[] b)

Test Case 1:
minTransformations({8,5,1,10,5,9,9}, {3,5,6,6,2,8,2}) = 21

Test Case 2:
minTransformations({1,8}, {9,1}) = 2

Test Case 3:
minTransformations({1,5,10}, {5,10,1}) = 2

Test Case 4:
minTransformations({9,6,8,7,2,9}, {10,3,8,10,6,5}) = 12

Test Case 5:
minTransformations({2,3,4,4}, {5,2,2,4}) = 3

Test Case 6:
minTransformations({8,5}, {3,8}) = 3

Test Case 7:
minTransformations({10,4,2,10}, {9,7,6,1}) = 8

Test Case 8:
minTransformations({9,7}, {1,3}) = 12

Test Case 9:
minTransformations({9}, {7}) = 2

Test Case 10:
minTransformations({1,10,1,1,7,2}, {4,9,10,4,5,5}) = 20
```