전체 글 (644) 썸네일형 리스트형 프로그래머스 : 다리를 지나는 트럭 package excercise; import java.util.LinkedList; import java.util.Queue; public class 다리를지나는트럭 { public static void main(String[] args) { int bridge_length = 2; int weight = 10; int[] truck_weights = { 7, 4, 5, 6 }; System.out.println(new 다리를지나는트럭().solution(bridge_length, weight, truck_weights)); } public int solution(int bridge_length, int weight, int[] truck_weights) { int answer = 0; int tota.. 프로그래머스 : 기능개발 package excercise; import java.util.ArrayList; import java.util.List; public class 기능개발 { public int[] solution(int[] progresses, int[] speeds) { int completeTime[] = new int[progresses.length]; List list = new ArrayList(); for (int i = 0; i < progresses.length; i++) { completeTime[i] = (100 - progresses[i] + speeds[i] - 1) / speeds[i]; } int pivot = 0; for (int time = 0; time 프로그래머스 : 주식가격 package excercise; import java.util.Arrays; import java.util.Stack; public class 주식가격 { public static void main(String[] args) { int prices[] = { 1, 2, 3, 2, 3, 2 }; System.out.println(Arrays.toString(new 주식가격().solution(prices))); } static class Pair { int time; int price; public Pair(int time, int price) { super(); this.time = time; this.price = price; } } public int[] solution(int[] prices) {.. 프로그래머스 : 베스트앨범 package excercise; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.PriorityQueue; import java.util.Queue; import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; public class 베스트앨범 { public static void main(String[] args) { String[] genres = { "classic", "pop", "classic", "classic", "p.. 프로그래머스 : 위장 package excercise; import java.util.HashMap; import java.util.Map; import java.util.Set; public class 위장 { public int solution(String[][] clothes) { Map hash = new HashMap(); for (int i = 0; i < clothes.length; i++) { String kind = clothes[i][1]; hash.put(kind, hash.getOrDefault(kind, 0) + 1); } int answer = 1; Set keys = hash.keySet(); for (String key : keys) { answer *= hash.get(key) + 1; } re.. 프로그래머스 : 전화번호목록 package excercise; import java.util.HashMap; import java.util.Map; public class 전화번호목록 { public static void main(String[] args) { String phone_book[] = { "119", "97674223", "1195524421" }; System.out.println(new 전화번호목록().solution(phone_book)); } public boolean solution(String[] phone_book) { Map hash[] = new HashMap[21]; for (int i = 1; i 프로그래머스 : 완주하지 못한 선수 N^2 으로 일일이 찾아가면서 제거할려면 많은 시간이 소요된다. HashMap으로 탐색시간을 줄여야한다. package hash; import java.util.HashMap; import java.util.Map; import java.util.Set; public class h1 { public String solution(String[] participant, String[] completion) { StringBuilder answer = new StringBuilder(); Map hash = new HashMap(); for (String str : participant) { if (hash.containsKey(str)) { int tmp = hash.get(str); hash.put(str.. javascript : 상속 function Rectangle(w, h) { var width = w; var height = h; this.getWidth = function () { return width; }; this.getHeight = function () { return height; }; this.setWidth = function (w) { if (w < 0) { throw '길이는 음수일 수 없습니다.'; } else { width = w; } }; this.setHeight = function (h) { if (h < 0) { throw '길이는 음수일 수 없습니다.'; } else { height = h; } }; } Rectangle.prototype.getArea = function () { return t.. 이전 1 ··· 24 25 26 27 28 29 30 ··· 81 다음