• Skip to primary navigation
  • Skip to content
  • Skip to footer
Dev Battery Dev Battery Keep your battery charged
    Wonjun Jeong

    Wonjun Jeong

    Backend Developer

    • Korea Republic
    • Email
    • GitHub
  • All Posts (863)
    • 🍀 Diary
      • Today I Learned (226)
    • 📈 Algorithm
      • Recap (4)
      • LeetCode (116)
      • HackerRank (130)
      • Codeforces (43)
      • Programmers (88)
      • Baekjoon (153)
      • Inflearn (2)
    • 📒 Issue
      • Project (23)
    • 🧑🏻‍💻 Programming
      • DevOps (3)
      • Java (15)
      • Spring (21)
      • FastAPI (0)
      • Vue (1)
      • React (2)
    • 🖥️ Computer Science
      • Network (7)
      • Database (10)
      • Data Structure (13)

    [Programmers] 부족한 금액 계산하기 (Java)

    Published: 2023-01-14
    Updated: 2023-01-14

    On this page

    • Solution
    • Reference


    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;
            }
        }
    }
    

    Tags: algorithms

    Categories: Programmers

    Published: 2023-01-14
    Updated: 2023-01-14

    Previous Next

    Leave a comment

    You may also enjoy

    [TIL] 신입 개발자 공부/일 26일차

    Published: 2026-01-21
    Updated: 2026-01-21

    work

    [TIL] 신입 개발자 공부/일 26일차

    Published: 2026-01-21
    Updated: 2026-01-21

    work

    [TIL] 신입 개발자 공부/일 26일차

    Published: 2026-01-21
    Updated: 2026-01-21

    work

    [TIL] 신입 개발자 공부/일 25일차

    Published: 2026-01-20
    Updated: 2026-01-20

    work