
Problem
Solution
Submissions
Find the Greatest of Three Numbers
Certification: Basic Level
Accuracy: 69.49%
Submissions: 118
Points: 5
Write a Python program that finds the largest among three given numbers.
Example 1
- Input: numbers = [10, 20, 30]
- Output: 30
- Explanation:
- Step 1: Take three numbers 10, 20, and 30 as input.
- Step 2: Compare the numbers to find the largest.
- Step 3: 30 is greater than both 10 and 20, so return 30.
Example 2
- Input: numbers = [-5, -2, -10]
- Output: -2
- Explanation:
- Step 1: Take three numbers -5, -2, and -10 as input.
- Step 2: Compare the numbers to find the largest.
- Step 3: -2 is greater than both -5 and -10, so return -2.
Constraints
- -10^9 ≤ numbers ≤ 10^9
- Time Complexity: O(1)
- Space Complexity: O(1)
Editorial
My Submissions
All Solutions
Lang | Status | Date | Code |
---|---|---|---|
You do not have any submissions for this problem. |
User | Lang | Status | Date | Code |
---|---|---|---|---|
No submissions found. |
Solution Hints
- Use nested if-else statements: if a > b and a > c: return a
- Use the max() function: max(a, b, c)
- Use sorted list: sorted([a, b, c])[-1]
- Use ternary operator: max_ab = a if a > b else b; return max_ab if max_ab > c else c