702. Largest Element

Given an array of integers nums, return the value of the largest element in the array

Example 1:

Input: nums = [3, 3, 6, 1]

Output: 6

Explanation: The largest element in array is 6

Example 2:

Input: nums = [3, 3, 0, 99, -40]

Output: 99

Explanation: The largest element in array is 99

Now Your Turn!

Pick the correct output for the given input

Input: nums = [-4, -3, 0, 1, -8]

Still unsure what the problem is asking ?

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

Constraints:

  • 1 <= nums.length <= 105
  • -104 <= nums[i] <= 104
  • nums may contain duplicate elements.

Hints

Frequently Occurring Doubts

Interview Follow-up Questions

0
class Solution {
public:
int largestElement(vector<int>& nums) {
 
}
};
Test Case

Input:

Nums