[Programmers] 120810번 - 나머지 구하기 [Java][C++]
[Programmers] 120810번 - 나머지 구하기 [Java][C++]
1. 아이디어
num1를 num2로 나눈 나머지를 return하는 문제로 모듈러 연산자를 활용하면 된다.
2. 복잡도
| 시간복잡도 | 공간복잡도 |
|---|---|
| $O(1)$ | $O(1)$ |
3. 코드
풀이 [Java][C++]
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;
}
This post is licensed under CC BY 4.0 by the author.