Interview Query

Finding the Maximum Number in a List

Start Timer

0:00:00

Upvote
2
Downvote
Save question
Mark as completed
View comments (4)
Next question

Given a list of integers, write a function that returns the maximum number in the list. If the list is empty, return None.

Example 1:

Input:

nums = [1, 7, 3, 5, 6]

Output:

find_max(nums) -> 7

Example 2:

Input:

nums = []

Output:

find_max(nums) -> None
.
.
.
.
.


Comments

Loading comments