Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Largest Number in Array

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Largest Number in Array. Start with the requirements on the right.

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.

Problem

The Western Digital Dashboard may provide QA test data as an array of numeric SMART metric readings. Write a function that returns the largest number in a non-empty array without sorting the array or using a built-in maximum function.

Formal Specification

Implement find_largest(nums), where nums is a non-empty list of integers. Return the greatest integer in nums. The input list must not be modified.

Constraints

  • 1 <= len(nums) <= 100000
  • -10^9 <= nums[i] <= 10^9
  • Values may be positive, zero, or negative.
  • Duplicate values are allowed.
  • Do not sort the array or call max().
  • Preserve the input array.

Function Signature

def find_largest(nums):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output