전체 글215 [Java] 프로그래머스 [Level-3] 정수 삼각형 public class Solution { // 정수 삼각형 public static int solution(int[][] triangle) { int answer = 0; int[][] dpTriangle = new int[triangle.length][triangle.length]; dpTriangle[0][0] = triangle[0][0]; for (int i = 1; i < triangle.length; i++) { // 가장 왼쪽 dpTriangle[i][0] = dpTriangle[i - 1][0] + triangle[i][0]; // 나머지 for (int j = 1; j < i; j++) { dpTriangle[i][j] = Math.max(dpTriangle[i - 1][j - 1], .. 2022. 11. 29. [Java] 프로그래머스 [Level-3] 다단계 칫솔 판매 import java.util.HashMap; public class Solution { // 다단계 칫솔 판매 // 칫솔의 가격 100원 // 10%를 추천인에게 주며, 원 단위에서 절사한다. 그 금액이 1원 미만인 경우 분배하지 않고 갖는다. static int[] answer = {}; static String[] globalEnroll = {}; static String[] globalReferral = {}; static HashMap hm; public static void RevenueShare(String member, int money) { int tempIndex = 0; int shareMoney = 0; if ("-".equals(member) || money == 0) { retu.. 2022. 11. 29. [Java] 프로그래머스 [Level-3] 보석 쇼핑 import java.util.*; public class Solution { // 보석 쇼핑 public static int[] solution(String[] gems) { int[] answer = new int[2]; int length = Integer.MAX_VALUE; int startIndex = 0; int exceptCnt = 0; String tempGem = ""; HashSet hs = new HashSet(Arrays.asList(gems)); HashMap hm = new HashMap(); Queue q = new LinkedList(); for (int i = 0; i < gems.length; i++) { hm.put(gems[i], hm.getOrDefault(gems[.. 2022. 11. 29. [Java] 프로그래머스 [Level-1] 햄버거 만들기 public class Solution { // 햄버거 만들기 // 빵(1), 야채(2), 고기(3), 빵(1)일 경우 햄버거 완성 public static int solution(int[] ingredient) { int answer = 0; StringBuilder sb = new StringBuilder(); for (int i = 0; i 3 && sb.subSequence(sb.length() - 4, sb.length()).equals("1231")) { sb.delete(sb.length() - 4, sb.length()); answer++; } } return a.. 2022. 11. 28. [Java] 프로그래머스 [Level-2] 주식가격 import java.util.Stack; public class Solution { // 주식가격 public static int[] solution(int[] prices) { int[] answer = new int[prices.length]; Stack stack = new Stack(); for (int i = 0; i pr.. 2022. 11. 28. [Java] 프로그래머스 [Level-3] 여행경로 import java.util.ArrayList; import java.util.Collections; public class Solution { // 여행경로 // 주어진 항공권을 모두 이용하여 여행경로를 짜려고 합니다. 항상 "ICN" 공항에서 출발합니다. // 주어진 공항 수는 3개 이상 10,000개 이하입니다. // 주어진 항공권은 모두 사용해야 합니다. // 만일 가능한 경로가 2개 이상일 경우 알파벳 순서가 앞서는 경로를 return 합니다. // 모든 도시를 방문할 수 없는 경우는 주어지지 않습니다. static boolean[] visited; static ArrayList travelRouteList; public static void dfs(String start, String rou.. 2022. 11. 28. 이전 1 ··· 25 26 27 28 29 30 31 ··· 36 다음