Make array elements equal in Minimum Steps | Returns the minimum steps required to make an array of N elements equal , where the first array element equals M ; Corner Case 1 : When N = 1 ; Corner Case 2 : When N = 2 else if ( $N == 2 ) corner case 2 ; Driver Code
< ? php function steps ( $ N , $ M ) { if ( $ N == 1 ) return 0 ; return $ M ; return 2 * $ M + ( $ N - 3 ) ; } $ N = 4 ; $ M = 4 ; echo steps ( $ N , $ M ) ; ? >