Skip to content

Instantly share code, notes, and snippets.

@DongguemYoo
Created May 1, 2020 06:24
Show Gist options
  • Save DongguemYoo/d77adb21a5c2eacd4c2406bb46ceebc6 to your computer and use it in GitHub Desktop.
Save DongguemYoo/d77adb21a5c2eacd4c2406bb46ceebc6 to your computer and use it in GitHub Desktop.
코딩테스트 연습 두 정수 사이의 합
public class Solution {
public long solution(int a, int b) {
long answer = 0;
(var minValue, var maxValue) = a > b ? (b, a) : (a, b); //3항 연산자 특이하게 쓰는법
for (int num = minValue; num <= maxValue; num++)
answer += num;
return answer;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment