Maximum Element in Array

You are given an array of N integers.

Your task is to find and return the maximum element present in the array.

Example 1:

Input: nums = [3, 7, 1, 2, 5]

Output: 7

Example 2:

Input: nums = [2, 10, 56, -14]

Output: 56

Now Your Turn!

Pick the correct output for the given input

Input: nums = [-20, -56, -89, -100]

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • 1 <= N <= 100
  • -100 <= nums[i] <= 100
0
class Solution {
public:
int findMax(vector<int>& nums) {
//your code goes here
}
};
Test Case

Input:

Nums