Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Find Largest Element in Array
00:00
5 left

Find Largest Element in Array

EasyPython

Problem

Write a function to find the largest element in an array. Implement def 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

def largest_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.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.