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

Maximum Element in Array

EasyPython

Problem

Find the maximum element in an array

Asked in the technical interview 1 stage. Basic coding.

Implement max_element(nums) to return the largest integer in the non-empty array nums. The function must return an integer and should solve the problem without sorting the array.

Input: a non-empty list of integers. Output: the maximum integer in the list.

Constraints: 1 <= len(nums) <= 1000; -10^9 <= nums[i] <= 10^9.

Constraints

  • 1 <= len(nums) <= 1000
  • -10^9 <= nums[i] <= 10^9
  • The array contains at least one element

Function Signature

def max_element(nums):
Interviewer

Your question is Maximum 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.