Find minimum absolute difference between two numbers of an array

Given an array (A) of N elements of positive integers .
Then find minimum absolute difference between two numbers of an array .
We can perform following operations on elements of array any number of times

  • if A[i] is EVEN ,then we can replace it by A[i]/2

  • if A[i] is ODD,then we can replace it by 2*A[i]

can any one explain @anon55659401 how to solve this kind of problems :pray:
This is problem from Hacker earth contest which was ended now .

lets say u have visited i , so all 0 to i-1 are accessible from i and there at most logn state for each i put that into set, and using set lower bound, find nearest element to both A[i], and all states of A[i] is its even and 2*A[i] if it is odd, total there are log2(A[i])+1 states, always update minimum,and then put all these log2(A[i]) number of elements in set, and work same for i+1 and final minimum will minimum of all.