자바/프로그래머스(36)
-
[Programmers/JAVA] 기능개발
내 코드 import java.util.*; class Solution { public int[] solution(int[] progresses, int[] speeds) { int[] answer; //queue 생성 Queue queue=new LinkedList(); //100%달성시까지 걸린 날짜 count해서 queue에 넣어줌 int index=0; for(int prog:progresses) { int count=0; while(prog
2023.02.16 -
[Programmers/JAVA] [1차] 캐시
내 코드 import java.util.LinkedHashMap; class Solution { public int solution(int cacheSize, String[] cities) { int answer = 0; //LinkedHashMap을 이용하여 순서있게 값을 저장하려고 함. LinkedHashMap list = new LinkedHashMap(){ @Override//removeEldestEntry를 오버라이드해서 list의 size가 cacheSize보다 커지면 오래된 값을 삭제함. protected boolean removeEldestEntry(java.util.Map.Entry eldest) { return size() == cacheSize+1 ? true : false; } };..
2023.02.15 -
[Programmers/JAVA] 위장
내 코드 import java.util.*; class Solution { public int solution(String[][] clothes) { int answer = 0; //hashset을 이용하여 중복업이 list에 옷 종류만 담기 HashSet set=new HashSet(); List clothes_subject=new ArrayList(); for(int i=0; i
2023.02.14 -
[Programmers/JAVA] 튜플
내 코드 import java.util.*; class Solution { public int[] solution(String s) { //s를 요소들만 빼서 리스트로 만들기 String[] s_split=s.split("},"); for(int i=0; i
2023.02.13 -
[Programmers/JAVA] 행렬의 곱셈
내 코드 class Solution { public int[][] solution(int[][] arr1, int[][] arr2) { int[][] answer = new int[arr1.length][arr2[0].length]; for(int i=0; i
2023.02.10 -
[Programmers/JAVA] 괄호 회전하기
내 코드 class Solution { public int solution(String s) { int answer = 0; String s1="\\[\\]"; // ""속에 특정 기호들을 넣을 때는 \\ 이걸 써줘야함. String s2="\\(\\)"; String s3="\\{\\}"; for(int i=0; i
2023.02.09