Post

[Programmers] #120802 - 두 수의 합 구하기 [Java][C++][Python]

[Programmers] #120802 - 두 수의 합 구하기 [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.