From b127f018a4bc6f6dd2e77c73dac7a44f14c4b27c Mon Sep 17 00:00:00 2001 From: Hongjoo Date: Mon, 30 Jun 2025 20:10:42 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[BOJ]#13549.=20=EC=88=A8=EB=B0=94=EA=BC=AD?= =?UTF-8?q?=EC=A7=883/Gold5/=EC=8B=A4=ED=8C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acmicpc.net/problem/13549 --- ...0\353\260\224\352\274\255\354\247\2103.py" | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 "Hongjoo/\353\260\261\354\244\200/\354\210\250\353\260\224\352\274\255\354\247\2103.py" diff --git "a/Hongjoo/\353\260\261\354\244\200/\354\210\250\353\260\224\352\274\255\354\247\2103.py" "b/Hongjoo/\353\260\261\354\244\200/\354\210\250\353\260\224\352\274\255\354\247\2103.py" new file mode 100644 index 0000000..2040ab5 --- /dev/null +++ "b/Hongjoo/\353\260\261\354\244\200/\354\210\250\353\260\224\352\274\255\354\247\2103.py" @@ -0,0 +1,31 @@ +import sys +from collections import deque +input = sys.stdin.readline +MAX = 100000 +N , K = map(int, input().split()) +visited = [MAX] * (MAX+1) # 방문 여부 +# 2. BFS로 N-> K 의 모든 경로 찾기 +t=0 +q = deque([N , t]) +visited[N]= 0 + + +while q : + cx= q.popleft() + ct =visited[cx] + for nx in (cx-1 , cx+1 , 2*cx) : + if 0 <= nx < MAX : + # 시간 업데이트 + if nx == 2*cx : + nt = ct + else : + nt = ct+1 + + if visited[nx] >= MAX : # 처음 도달 + q.append(nx) + visited[nx] = nt + else : # 중복& 최단 거리일때 + if nt < visited[nx] : + visited[nx] = nt + q.append(nx) +print(visited[K]) \ No newline at end of file From 3751db541f3441585c40911e1f4ea1c460be1f98 Mon Sep 17 00:00:00 2001 From: Hongjoo Date: Mon, 30 Jun 2025 20:14:19 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[PGS]#17684.=20[3=EC=B0=A8]=5F=EC=95=95?= =?UTF-8?q?=EC=B6=95/lv2/1h40min?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://programmers.co.kr/learn/courses/30/lessons/17684 --- ...3\354\260\250_\354\225\225\354\266\225.py" | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 "Hongjoo/lv2/3\354\260\250_\354\225\225\354\266\225.py" diff --git "a/Hongjoo/lv2/3\354\260\250_\354\225\225\354\266\225.py" "b/Hongjoo/lv2/3\354\260\250_\354\225\225\354\266\225.py" new file mode 100644 index 0000000..3fae74b --- /dev/null +++ "b/Hongjoo/lv2/3\354\260\250_\354\225\225\354\266\225.py" @@ -0,0 +1,34 @@ +""" +## 프로그래머스#17684. [3차]_압축: 구현 / lv2 +> 문제 링크 : https://school.programmers.co.kr/learn/courses/30/lessons/17684 +""" +def solution(msg): + answer = [] + # 1. 사전 초기기 + dict = {} + idx = 1 # 초기 사전 idx + for o in range(65, 65+ 26) : + dict[chr(o)] = idx + idx += 1 + last_idx = idx-1 + #2. 입출력 단어 압축하기 + prev_idx = -1 + w_s = 0 ; w_l = 1 + while w_s+w_l <= len(msg) : + word = msg[w_s : w_s + w_l] + idx = dict.get(word , -1 ) + if idx > -1 : + prev_idx = idx + w_l += 1 + continue + #사전에 없음 + else : + last_idx += 1 + dict[word] = last_idx # 사전 등록하기 + w_s = w_s + w_l - 1 #탐색 point 업데이트 + w_l = 1 # 단어 길이 초기화 + answer+= [prev_idx]# 이전 존재한 단어의 idx 는 출력 리스트에 추가 + answer+= [prev_idx] # 마지막 w 의 인덱스 출력 + + + return answer \ No newline at end of file From 360bdf810b0d4fe72bea1240bd6d18c41cddf5f9 Mon Sep 17 00:00:00 2001 From: Hongjoo Date: Mon, 30 Jun 2025 20:16:06 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[PGS]#49993.=20=EC=8A=A4=ED=82=AC=ED=8A=B8?= =?UTF-8?q?=EB=A6=AC/lv2/49993min?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://programmers.co.kr/learn/courses/30/lessons/49993 --- ...44\355\202\254\355\212\270\353\246\254.py" | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 "Hongjoo/lv2/\354\212\244\355\202\254\355\212\270\353\246\254.py" diff --git "a/Hongjoo/lv2/\354\212\244\355\202\254\355\212\270\353\246\254.py" "b/Hongjoo/lv2/\354\212\244\355\202\254\355\212\270\353\246\254.py" new file mode 100644 index 0000000..4f8b556 --- /dev/null +++ "b/Hongjoo/lv2/\354\212\244\355\202\254\355\212\270\353\246\254.py" @@ -0,0 +1,25 @@ + +# skillset이 선행조건 충족 여부 확인 함수 +def check_skill(words , skill) : + set_p = 0 ; + for c in words : + # 해당 스킬(c) 가 선행스킬 속 존재여부 파악 및 순번 확인 + idx = skill.find(c) + if idx < 0 : # ok + continue + elif idx == set_p : # ok + set_p +=1 + continue + else : + # 선행 스킬 순서 보다 더 이르게 w 스킬이 등장한 경우 + return False + return True + +def solution(skill, skill_trees): + answer = 0 + # 반복문올 skill_tree 속 선행스킬 조건에 충족하는 스킬 확인 및 개수 계산 + for skillset in skill_trees : + if check_skill(skillset , skill) : + answer += 1 + + return answer \ No newline at end of file From 5d733f33fe4d291319fff8499be14098d7a4819d Mon Sep 17 00:00:00 2001 From: Hongjoo Date: Mon, 30 Jun 2025 20:47:56 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[PGS]#42586.=20=EA=B8=B0=EB=8A=A5=EA=B0=9C?= =?UTF-8?q?=EB=B0=9C/lv2/30min?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://programmers.co.kr/learn/courses/30/lessons/42586 --- ...60\353\212\245\352\260\234\353\260\234.py" | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 "Hongjoo/lv2/\352\270\260\353\212\245\352\260\234\353\260\234.py" diff --git "a/Hongjoo/lv2/\352\270\260\353\212\245\352\260\234\353\260\234.py" "b/Hongjoo/lv2/\352\270\260\353\212\245\352\260\234\353\260\234.py" new file mode 100644 index 0000000..2112a82 --- /dev/null +++ "b/Hongjoo/lv2/\352\270\260\353\212\245\352\260\234\353\260\234.py" @@ -0,0 +1,27 @@ +""" +## 프로그래머스#42586. 기능개발 : 구현, 큐/lv2 +> 문제 링크 : https://school.programmers.co.kr/learn/courses/30/lessons/42586 + +""" +import math +from collections import deque +def solution(progresses, speeds): + answer = [] + # 1. progress별로 추가 Day 구하기 + days= deque([0 for _ in range(len(progresses))]) + for i in range(len(progresses)) : + days[i] = math.ceil((100 - progresses[i]) / speeds[i]) + # print(days) + #2. 같은 배포일을 가진 서비스 개수들 구하기 + while days : + tmp = 0 + develop_day = days[0] + # deque로 develop_days보다 더 빠르게 종료되는 서비스들은 pop + while days and develop_day >= days[0] : + tmp += 1 + days.popleft() + # 해당 develop_day보다 큰 경우, 그 전까지 서비스들이 같은 배포일 가짐 + answer.append(tmp) + + + return answer \ No newline at end of file