• Input: [2, 14, 5, 53, 26, 33, 12, 8, 9]
  • Output: 53
  • Assumption: Input contains at least one number.

 


 

  • Quick code using max() or list sort()
numbers = [2, 14, 5, 53, 26, 33, 12, 8, 9]
largest = max(numbers)
print(largest)

 


 

  • Interviewer: Rewrite without max().
numbers = [2, 14, 5, 53, 26, 33, 12, 8, 9]
largest = -math.inf
for num in numbers:
    if num > largest:
        largest = num
print(largest)