두 정수 사이의 합

이준경·2021년 5월 12일
0

<나의풀이>

1
2
3
4
5
6
7
8
9
10
11
12
13
class Solution {
  public long solution(int a, int b) {
        long answer = 0;
        if (a==b) {
            return a;
        }else {
            for (int i=Math.min(a, b);i <= Math.max(a, b); i++) {
                answer+=i;
            }
            return answer;
        }
  }
}
cs

0개의 댓글

관련 채용 정보