inblog logo
|
stupefyee
    알고리즘문제풀기

    [JAVA 문제 풀이] 205. 커피 심부름

    프로그래머스 (181837)
    Stupefyee's avatar
    Stupefyee
    Apr 16, 2025
    [JAVA 문제 풀이] 205. 커피 심부름
    Contents
    내가 작성한 코드다른 사람의 코드
    school.programmers.co.kr
    https://school.programmers.co.kr/learn/courses/30/lessons/181837
    notion image
     

    내가 작성한 코드

    class Solution { public int solution(String[] order) { int americanoCount = 0; int cafelatteCount = 0; for(String s : order) { if(s.contains("americano") || s.contains("anything")) { americanoCount++; } else if(s.contains("cafelatte")) { cafelatteCount++; } } return americanoCount * 4500 + cafelatteCount * 5000; } }
     

    다른 사람의 코드

    class Solution { public int solution(String[] order) { int answer = 0; for(String menu : order) { answer += menu.contains("cafelatte") ? 5000 : 4500; } return answer; } }
    Share article
    Contents
    내가 작성한 코드다른 사람의 코드

    stupefyee

    RSS·Powered by Inblog