Skip to content

Commit 8d3d45d

Browse files
committed
[level 1] Title: 두 정수 사이의 합, Time: 8.58 ms, Memory: 80.4 MB -BaekjoonHub
1 parent 301f9db commit 8d3d45d

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

프로그래머스/1/12912. 두 정수 사이의 합/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# [level 1] 두 정수 사이의 합 - 12912
22

3-
[문제 링크](https://school.programmers.co.kr/learn/courses/30/lessons/12912?language=java)
3+
[문제 링크](https://school.programmers.co.kr/learn/courses/30/lessons/12912)
44

55
### 성능 요약
66

7-
메모리: 74.3 MB, 시간: 8.58 ms
7+
메모리: 80.4 MB, 시간: 8.58 ms
88

99
### 구분
1010

@@ -16,7 +16,7 @@
1616

1717
### 제출 일자
1818

19-
2026년 06월 18일 16:55:17
19+
2026년 06월 21일 13:39:18
2020

2121
### 문제 설명
2222

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
import java.math.*;
2-
31
class Solution {
42
public long solution(int a, int b) {
5-
long answer = 0;
6-
int c = Math.min(a, b);
7-
int d = Math.max(a, b);
8-
for (int i = c;i <= d; i++){
9-
answer += i;
3+
long res = 0L;
4+
if (a>b){
5+
for (int i = b; b <= a; b++) {
6+
res += b;
7+
}
108
}
11-
return answer;
9+
else {
10+
for (int i = a; a <= b; a++) {
11+
res += a;
12+
}
13+
}
14+
return res;
1215
}
1316
}

0 commit comments

Comments
 (0)