728x90
다트 게임
-
프로그래머스 (Level 1) - 다트 게임Coding Test/Coding Test 문제 풀이 2021. 12. 25. 16:53
문제 설명 코딩테스트 연습 - [1차] 다트 게임 programmers.co.kr 풀이 다른 자료구조나 알고리즘이 필요한 방식이 아닌, 평범한 구현 문제였다. 문제 설명에서 주어진 보너스, 옵션에 부합하도록 점수를 조정해주면 되는 문제이다. 입력받은 문자열의 문자를 하나씩 탐색하면서 점수, 보너스, 옵션을 조건문으로 분리하며 풀이를 했다. 점수에 해당하는 인덱스를 적절하게 조정해서 보너스 또는 옵션을 부여하는 것이 핵심이었다. 전체 소스코드 import java.io.*; import java.util.*; public class Main { public int solution(String dartResult) { int[] points = new int[3]; int index = -1; for (in..