You are viewing a single comment's thread. Return to all comments →
If the problem statement is exactly the same, and you were asked to find the minimum, you simply loop through the array using Math.min() instead of the Math.max() in the last loop in this solution.
The resulting array will have all M operations performed on it. We can find the max/min/mean/median/mode, whatever we want, since it's just an array of final values. I can take a look at your code (if you want to alter this solution to see why it didn't work.