Easy

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 are a and c. The third number (b) equals 7, which is the answer.

Input/Output

  • [execution time limit] 0.5 seconds (c)

  • [input] integer a

    Guaranteed constraints:
    1 ≤ a ≤ 10^9.

  • [input] integer b

    Guaranteed constraints:
    1 ≤ b ≤ 10^9.

  • [input] integer c

    Guaranteed constraints:
    1 ≤ c ≤ 10^9.

  • [output] integer

[C] Syntax Tips

// Prints help message to the console
// Returns a string
char * helloWorld(char * name) {
    char * answer = malloc(strlen(name) + 8);
    printf("This prints to the console when you Run Tests");
    strcpy(answer, "Hello, ");
    strcat(answer, name);
    return answer;
}

더보기

Solution

int extraNumber(int a,int b,int c)
{
	return a==b&&a!=c?c:a==c&&a!=b?b:a;
}
728x90

'Codesignal' 카테고리의 다른 글

<Codesignal> Arithmetic Expression  (0) 2020.04.07
<Codesignal> Is Infinite Process?  (0) 2020.04.07
<Codesignal> Reach Next Level  (0) 2020.04.07
<Codesignal> Phone Call  (0) 2020.04.07
<Codesignal> Late Ride  (0) 2020.04.07

+ Recent posts