Javascript – min steps to make all elements equal to each other
Here is the detail: Eg: [1,1,2,4] (init) -> gen1 [2,1,2,4] -> gen2 [4,1,2,4] -> gen3 [4,2,2,4] -> gen4 [4,4,2,4] -> gen5 (no change) -> gen6 [4,4,4,4] each generation: odd step: +1 or zero even step: +2 or zero in order…