From 206a48bfb1923d262002e85f3f7adb4a371f492b Mon Sep 17 00:00:00 2001 From: gracekim527 Date: Mon, 22 Apr 2024 19:48:19 +0900 Subject: [PATCH 1/7] =?UTF-8?q?[PSG]=20=EC=A3=BC=EC=8B=9D=EA=B0=80?= =?UTF-8?q?=EA=B2=A9=20/=20Level=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\354\243\274\354\213\235\352\260\200\352\262\251.py" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "Grace/stack_queue/\354\243\274\354\213\235\352\260\200\352\262\251.py" diff --git "a/Grace/stack_queue/\354\243\274\354\213\235\352\260\200\352\262\251.py" "b/Grace/stack_queue/\354\243\274\354\213\235\352\260\200\352\262\251.py" new file mode 100644 index 0000000..e69de29 From de99e6fb2e2b7a8a764ebe095e97b84244a394a0 Mon Sep 17 00:00:00 2001 From: gracekim527 Date: Mon, 22 Apr 2024 21:18:46 +0900 Subject: [PATCH 2/7] =?UTF-8?q?[PSG]=20=ED=94=84=EB=A1=9C=EC=84=B8?= =?UTF-8?q?=EC=8A=A4=20/=20Level=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...204\353\241\234\354\204\270\354\212\244.py" | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 "Grace/stack_queue/\355\224\204\353\241\234\354\204\270\354\212\244.py" diff --git "a/Grace/stack_queue/\355\224\204\353\241\234\354\204\270\354\212\244.py" "b/Grace/stack_queue/\355\224\204\353\241\234\354\204\270\354\212\244.py" new file mode 100644 index 0000000..4d615aa --- /dev/null +++ "b/Grace/stack_queue/\355\224\204\353\241\234\354\204\270\354\212\244.py" @@ -0,0 +1,18 @@ +from collections import deque + +def solution(priorities, location): + answer = [] + queue = deque((i, j) for i, j in enumerate(priorities)) + + while queue: + process = queue.popleft() + # 우선순위가 더 높은 프로세스가 하나라도 있으면 큐에 다시 추가 / 아니면 해당 프로세스 실행 + if queue and any(process[1] < q[1] for q in queue): + queue.append(process) + else: + answer.append(process) + + # location 실행 순서 찾기 + for i in answer: + if i[0] == location: + return answer.index(i)+1 \ No newline at end of file From 65a34303357f2d6850868ea9a96f6959259573c5 Mon Sep 17 00:00:00 2001 From: gracekim527 Date: Wed, 1 May 2024 16:55:21 +0900 Subject: [PATCH 3/7] =?UTF-8?q?[PGS]=20K=EB=B2=88=EC=A7=B8=EC=88=98=20/=20?= =?UTF-8?q?Level=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "Grace/sort/K\353\262\210\354\247\270\354\210\230.py" | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 "Grace/sort/K\353\262\210\354\247\270\354\210\230.py" diff --git "a/Grace/sort/K\353\262\210\354\247\270\354\210\230.py" "b/Grace/sort/K\353\262\210\354\247\270\354\210\230.py" new file mode 100644 index 0000000..aaf8965 --- /dev/null +++ "b/Grace/sort/K\353\262\210\354\247\270\354\210\230.py" @@ -0,0 +1,7 @@ +def solution(array, commands): + answer = [] + for i in range(len(commands)): + tmp_arr = array[commands[i][0]-1:commands[i][1]] + tmp_arr.sort() + answer.append(tmp_arr[commands[i][2]-1]) + return answer \ No newline at end of file From 708cddf6132f60cb9fbafadefff4ea4acee971d0 Mon Sep 17 00:00:00 2001 From: gracekim527 Date: Wed, 1 May 2024 17:53:04 +0900 Subject: [PATCH 4/7] =?UTF-8?q?[PGS]=20=EC=A0=84=ED=99=94=EB=B2=88?= =?UTF-8?q?=ED=98=B8=20=EB=AA=A9=EB=A1=9D=20/=20Level=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...62\210\355\230\270 \353\252\251\353\241\235.py" | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 "Grace/hash/\354\240\204\355\231\224\353\262\210\355\230\270 \353\252\251\353\241\235.py" diff --git "a/Grace/hash/\354\240\204\355\231\224\353\262\210\355\230\270 \353\252\251\353\241\235.py" "b/Grace/hash/\354\240\204\355\231\224\353\262\210\355\230\270 \353\252\251\353\241\235.py" new file mode 100644 index 0000000..5a7b010 --- /dev/null +++ "b/Grace/hash/\354\240\204\355\231\224\353\262\210\355\230\270 \353\252\251\353\241\235.py" @@ -0,0 +1,14 @@ +def solution(phone_book): + # 1. Hash map을 만든다 + hash_map = {} + for phone_number in phone_book: + hash_map[phone_number] = 1 + + for phone_number in phone_book: + jubdoo = "" + for number in phone_number: + jubdoo += number + + if jubdoo in hash_map and jubdoo != phone_number: + return False + return True \ No newline at end of file From 2fb79b6a2d91cefbf072c4dfede24294f0bf1d6a Mon Sep 17 00:00:00 2001 From: gracekim527 Date: Thu, 2 May 2024 23:31:51 +0900 Subject: [PATCH 5/7] =?UTF-8?q?[PGS]=20=ED=83=80=EA=B2=9F=20=EB=84=98?= =?UTF-8?q?=EB=B2=84=20/=20Level=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\352\262\237 \353\204\230\353\262\204.py" | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 "Grace/dfs_bfs/\355\203\200\352\262\237 \353\204\230\353\262\204.py" diff --git "a/Grace/dfs_bfs/\355\203\200\352\262\237 \353\204\230\353\262\204.py" "b/Grace/dfs_bfs/\355\203\200\352\262\237 \353\204\230\353\262\204.py" new file mode 100644 index 0000000..bb0a38a --- /dev/null +++ "b/Grace/dfs_bfs/\355\203\200\352\262\237 \353\204\230\353\262\204.py" @@ -0,0 +1,19 @@ +def solution(numbers, target): + leaves = [0] + answer = 0 # 카운트 + + for num in numbers: + temp = [] + + for leaf in leaves: + temp.append(leaf + num) + temp.append(leaf - num) + + leaves = temp + + # 타겟과 같은지를 확인 + for leaf in leaves: + if leaf == target: + answer += 1 + + return answer \ No newline at end of file From 1b48478b5a8213f513c75cc7f809847a5e25c7e3 Mon Sep 17 00:00:00 2001 From: gracekim527 Date: Wed, 8 May 2024 16:48:10 +0900 Subject: [PATCH 6/7] =?UTF-8?q?[PGS]=20=EC=9E=85=EA=B5=AD=EC=8B=AC?= =?UTF-8?q?=EC=82=AC=20/=20Level=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...05\352\265\255\354\213\254\354\202\254.py" | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 "Grace/binary_search/\354\236\205\352\265\255\354\213\254\354\202\254.py" diff --git "a/Grace/binary_search/\354\236\205\352\265\255\354\213\254\354\202\254.py" "b/Grace/binary_search/\354\236\205\352\265\255\354\213\254\354\202\254.py" new file mode 100644 index 0000000..6a843cd --- /dev/null +++ "b/Grace/binary_search/\354\236\205\352\265\255\354\213\254\354\202\254.py" @@ -0,0 +1,24 @@ +def solution(n, times): + # 6명이고 7분, 10분 걸림 각각 + left = 0 + right = max(times) * n + answer = 0 + + while left <= right: + mid = (left + right) // 2 + users = 0 # 심사한 사람 수 + + for time in times: + users += mid // time + # users가 n보다 큰 경우 탐색이 끝나야 한다. + if users >= n: + break + # users가 n명보다 초과해서 심사하였다면, 시간이 너무 많다는 것이다. + if users >= n: + answer = mid + right = mid -1 + # users가 n보다 미만으로 심사하였다면, 시간이 너무 부족한 것이다. + else: + left = mid + 1 + + return answer \ No newline at end of file From f48f70aa5b1c8eb34a4e570bfb55e71780d77226 Mon Sep 17 00:00:00 2001 From: gracekim527 Date: Thu, 9 May 2024 04:15:52 +0900 Subject: [PATCH 7/7] =?UTF-8?q?[PGS]=20N=EC=9C=BC=EB=A1=9C=20=ED=91=9C?= =?UTF-8?q?=ED=98=84=20/=20Level=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\274\353\241\234 \355\221\234\355\230\204.py" | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 "Grace/dynamic_programming/N\354\234\274\353\241\234 \355\221\234\355\230\204.py" diff --git "a/Grace/dynamic_programming/N\354\234\274\353\241\234 \355\221\234\355\230\204.py" "b/Grace/dynamic_programming/N\354\234\274\353\241\234 \355\221\234\355\230\204.py" new file mode 100644 index 0000000..3f6ed28 --- /dev/null +++ "b/Grace/dynamic_programming/N\354\234\274\353\241\234 \355\221\234\355\230\204.py" @@ -0,0 +1,16 @@ +def solution(N, number): + dp = [set([int(str(N) * i)]) for i in range(1, 9)] + + for i in range(8): + for j in range(i): + # j 개 + for num1 in dp[j]: + for num2 in dp[i-j-1]: + dp[i].add(num1 + num2) + dp[i].add(num1 - num2) + dp[i].add(num1 * num2) + if num2 != 0: + dp[i].add(num1 // num2) + if number in dp[i]: + return i+1 + return -1 \ No newline at end of file