[Programmers] 부족한 금액 계산하기 (Java)
Solution
class Solution {
public static long solution(int price, int money, int count) {
long sumPrice = 0;
for (int i = 1; i <= count; i++) {
sumPrice += (long) price * i;
}
if (money - sumPrice >= 0) {
return 0;
} else {
return sumPrice - money;
}
}
}
Leave a comment