1041. Greatest of Three Numbers

Given three real numbers a, b, and c (each may be positive, negative, integer, or decimal up to 6 places), return the greatest among them.

Example 1:

Input: a = 1, b = 3, c = 5  

Output: 5  

Explanation: 5 is greater than both 1 and 3.

Example 2:

Input: a = 1.123, b = 1.124, c = 1.125  

Output: 1.125  

Explanation: 1.125 is the greatest among the three decimal numbers.

Now Your Turn!

Pick the correct output for the given input

Input: a = -10.999999, b = -5.5, c = -1.000001  

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • -109 <= a, b, c <= 109
  • Precision up to 6 decimal places
0
class Solution {
public:
double greatestOfThree(double a, double b, double c) {
// Your code goes here
}
};
Test Case

Input:

A
B
C