Make two vectors equal to each other.

203 Views Asked by At

Consider you have a array $a=[x_1,x_2,x_3]$ and array $b=[y_1,y_2,y_3]$ and i need to convert $a$ to to $b$ using minimum number of operations. Valid operations are

  • Choose a integer $k$ (by integer i mean all positive ,or negative or zero) and a operation addition ,subtraction or multiplication

  • Choose a subset of elements of array $a$

  • Multiply or add or subtract $k$ to all elements of subset and position back them to their previous places .

My approach: I thought of creating a array $c$ which is equal to $a-b$ and a divisor array $d=[z_1,z_2,z_3]$ where $z_i=y_i/x_i$ each operation. Then according to the max occurrence of elements in these vector i will proceed further.

There is a upper bound on operations as i can make them agree by with single addition or subtraction. How do i find the minimum number of operations required?