문제
Three friends compare how many minutes they were late this week and the one who was late the least gets to pick lunch. Given the three numbers, find the smallest. Some values can be equal, and they can be negative (early).
Implement smallest_of_three(a, b, c).
Input
a: The first number.
b: The second number.
c: The third number.
Output
Return the smallest of the three values. If several are equal and smallest, return that value.
제약 조건
−10^18 ≤ a, b, c ≤ 10^18
예시
입력:
a = 7
b = 15
c = 3
예상 출력:
expected = 3
입력:
long long a = 7;
long long b = 15;
long long c = 3;
예상 출력:
long long expected = 3;
입력:
long a = 7;
long b = 15;
long c = 3;
예상 출력:
long expected = 3;
설명
3 is less than both 7 and 15.
입력:
a = -4
b = -4
c = 10
예상 출력:
expected = -4
입력:
long long a = -4;
long long b = -4;
long long c = 10;
예상 출력:
long long expected = -4;
입력:
long a = -4;
long b = -4;
long c = 10;
예상 출력:
long expected = -4;
설명
The two −4 values tie for smallest, so the answer is −4.
접근 방법
먼저 스스로 풀어 본 뒤 힌트를 하나씩 열어 보세요.
힌트 1
Assume the first number is the smallest.
힌트 2
Compare it with the second and then the third, updating when you find a smaller one.
힌트 3
Use a 64-bit integer type, the values can be very large.
예상 복잡도
O(1) time, O(1) extra space
참고 자료
이 문제는 CodeUtility에 맞게 수정되었습니다. 위의 설명과 제한 조건을 따르세요.