Back to Practice Dashboard
Python BasicsEasy

Greatest of the Three numbers

Learn how to solve the 'Greatest of the Three numbers' problem. This detailed resource details brute force and optimized approaches.

Problem Statement

Easy

Write a function greatest_of_three(a, b, c) that takes three integers a, b, and c and returns the greatest among them.

Constraints
  • -10^9 <= a, b, c <= 10^9

Examples

Example 1
Input
a = 10, b = 20, c = 15
Output
20
Explanation

20 is the largest among 10, 20, and 15.

Example 2
Input
a = 5, b = 5, c = 5
Output
5
Explanation

All three are equal, so return 5.

Example 3
Input
a = -1, b = -2, c = -3
Output
-1
Explanation

-1 is the greatest among -1, -2, and -3.

Need a Hint?
Use simple arithmetic operators (like modulo `%`, division `//`), conditional checks, or loops to inspect number properties.
Edge Cases to Watch
  • Empty list or null input variables
  • Single item lists/arrays
  • Extremely large input bounds causing integer or stack overflow

Ready to Solve?

Open the problem in PyRun's browser-based Python editor. Your code runs fully offline — no server required.

Open in Editor