Find the Largest Element in a List
Find the Largest Element in a List
Tags: Data Structures Basics
Credit: CodingChallenge
Difficulty: Beginner
Type: Text
Category: Practice
Time Allowed: 5 s
Description:
Write a function that takes a list of numbers and returns the largest element. This problem is designed to help you practice working with lists and finding maximum values
. The function should accept one parameter and return the largest element.
Constraints:
- The input will be a
list
of numbers (integers or floats). - The list will contain at least one element.
- The function should
return
anumber
representing the largest element.
Example:
- Input:
[1, 3, 2, 5, 4]
- Output:
5
Test Case | Input | Expected Output |
---|---|---|
1 | [1, 3, 2, 5, 4] | 5 |
2 | [-1, -3, -2, -5, -4] | -1 |
3 | [0, 0, 0] | 0 |
4 | [100] | 100 |
5 | [1.5, 2.5, 3.5] | 3.5 |
6 | [-1.5, -2.5, -0.5] | -0.5 |
7 | [42] | 42 |
Leave a Comment
Please login to leave a comment.