825. Greatest of Two Numbers

Given two real numbers a and b, return the greatest among the two. If both numbers are equal, return either of them.

Example 1:

Input: a = 1, b = 3

Output: 3

Explanation: 3 is greater than 1.

Example 2:

Input: a = 1.123, b = 1.124

Output: 1.124

Explanation: 1.124 is greater than 1.123.

Now Your Turn!

Pick the correct output for the given input

Input: a = -5, b = -2

Still unsure what the problem is asking ?

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

Constraints:

  • −10⁹ ≤ a, b ≤ 10⁹
  • Numbers can be integers or floating-point values (up to 6 decimal places)
0
class Solution {
public:
double greatestNumber(double a, double b) {
// Your code goes here
}
};
Test Case

Input:

A
B