[Programmers] #120803 - 두 수의 차 구하기 [Java][C++][Python]
정수 num1에서 num2를 뺀 값을 그대로 반환하는 워밍업 문제.
[Programmers] #120803 - 두 수의 차 구하기 [Java][C++][Python]
1. 아이디어
정수 num1, num2가 주어질 때, 두 수의 차를 반환하면 되는 간단한 문제다.
2. 복잡도
| 접근 | 시간 | 공간 |
|---|---|---|
| 풀이 | $O(1)$ | $O(1)$ |
3. 코드
풀이 [Java][C++][Python]
1
2
3
4
5
class Solution {
public int solution(int num1, int num2) {
return num1 - num2;
}
}
1
2
3
4
5
6
#include <bits/stdc++.h>
using namespace std;
int solution(int num1, int num2) {
return num1 - num2;
}
1
2
def solution(num1, num2):
return num1 - num2
This post is licensed under CC BY 4.0 by the author.