How i improve These Answer for less Memory and less time
using namespace std;
Every time there’s a pair of elements such that a>2*b, you need to insert elements between them, the number of inserted (or added) elements will be minimum when the elements would be of the form,
a,a*2,a*4,a*8........b, that is a GP, with r=2, a as first term, and last term<=b and >=b/2.
So you need to add
nearest integer less than log2(b/a), everytime you encounter such elements which do not satisfy the criteria.