Write a function to find the largest element in an array. Implement largest_element(nums), where nums is a non-empty array of integers. Return the largest integer in the array, including when all values are negative.
Constraints
1 <= nums.length <= 10^5
-10^9 <= nums[i] <= 10^9
The array is non-empty
Function Signature
deflargest_element(nums):
Interviewer
Your question is Find Largest Element in Array. Start with the requirements in the Question tab.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.