Minimum increments by index value required to obtain at least two equal Array elements | Function to calculate the minimum number of steps required ; Stores minimum difference ; Driver Code
function incrementCount ( arr , N ) { let mini = arr [ 0 ] - arr [ 1 ] ; for ( let i = 2 ; i < N ; i ++ ) { mini = Math . min ( mini , arr [ i - 1 ] - arr [ i ] ) ; } document . write ( mini ) ; } let N = 3 ; let arr = [ 12 , 8 , 4 ] ; incrementCount ( arr , N ) ;