Minimum steps required to reduce all the elements of the array to zero | C ++ implementation of the approach ; Function to return the minimum steps required to reduce all the elements to 0 ; Maximum element from the array ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int minSteps ( int arr [ ] , int n ) { int maxVal = * max_element ( arr , arr + n ) ; return maxVal ; } int main ( ) { int arr [ ] = { 1 , 2 , 4 } ; int n = sizeof ( arr ) / sizeof ( int ) ; cout << minSteps ( arr , n ) ; return 0 ; }