Extra Number

Description


You’re given three integers, a, b and c. It is guaranteed that two of these integers are equal to each other. What is the value of the third integer?

Example

For a = 2, b = 7, and c = 2, the output should be extraNumber(a, b, c) = 7.

The two equal numbers area and c. The third number (b) equals 7, which is the answer.

Input/Output

  • [execution time limit] 4 seconds (js)

  • [input] integer a

    Guaranteed constraints:
    1 \leq a \leq 109.

  • [input] integer b

    Guaranteed constraints:
    1 \leq b \leq 109.

  • [input] integer c

    Guaranteed constraints:
    1 \leq c \leq 109.

  • [output] integer

[JavaScript (ES6)] Syntax Tips

1
2
3
4
5
6
// Prints help message to the console
// Returns a string
function helloWorld(name) {
    console.log("This prints to the console when you Run Tests");
    return "Hello, " + name;
}

Solution


1
2
3
function extraNumber(a, b, c) {
	return a == b ? c : a == c ? b : a
}