This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def solution(X, Y): | |
| # ๊ณตํต์ ์ฐพ๊ณ | |
| # ํฐ์์๋๋ก ๋์ด | |
| x_counts = [0] * 10 | |
| y_counts = [0] * 10 | |
| for current_x in X : | |
| x_counts[int(current_x)] += 1 | |
| for current_y in Y : |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from collections import deque | |
| def solution(priorities, location): | |
| queues = deque((index,priority) for index, priority in enumerate(priorities)) | |
| count = 0 | |
| while queues: | |
| highest_priority = max(queues, key=lambda x: x[1])[1] | |
| current_index,current_priority = queues.popleft() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def solution(cards1, cards2, goal): | |
| for goal_card in goal : | |
| issame = False | |
| if cards1: | |
| if goal_card == cards1[0] : | |
| cards1.pop(0) | |
| issame = True | |
| if cards2: | |
| if goal_card == cards2[0] : |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def solution(progresses, speeds): | |
| ends = [] | |
| for prog, speed in zip(progresses, speeds) : | |
| end = (100 - prog)//speed | |
| end_remain = (100 - prog)%speed | |
| if end_remain : | |
| end += 1 | |
| ends.append(end) | |
| answer = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def function(N,K) : | |
| people = [num+1 for num in range(N)] | |
| result = [] | |
| current_index = 0 | |
| while people: | |
| current_index = (current_index + K-1) % len(people) # ์ถ๋ฐ ์ธ๋ฑ์ค ๋ฐ๊พธ๊ธฐ | |
| result.append(people.pop(current_index)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def solution(n, k, cmd): | |
| results = ['O'] * n | |
| deletes = [] # (์ด์ ํ, ํ์ฌํ, ๋ค์ํ)์ ํํ ๋ฆฌ์คํธ์ | |
| # n = ์ฒ์ ํ์ ํ ๊ฐ์ | |
| # k = ํ์ฌ ์์น | |
| table = {i: [i - 1, i + 1] for i in range(n)} # {ํ์ฌํ: [์ด์ ํ, ๋ค์ํ]} | |
| table[0][0] = None | |
| table[n - 1][1] = None | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def solution(board, moves): | |
| buckets = [] | |
| answer = 0 # ์ธํ ํฐ์ง ํ์ | |
| for move in moves : | |
| col = move - 1 | |
| for row in range(len(board)): | |
| doll_number = board[row][col] | |
| if doll_number : #0์ด ์๋๋ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def solution(prices): | |
| n = len(prices) | |
| answer = [0] * n | |
| for i in range(n): | |
| # ํ์ฌ ๊ฐ๊ฒฉ๋ณด๋ค ๋ค์ ์๋ ๊ฐ๊ฒฉ๋ค์ ํ๋์ฉ ํ์ธ | |
| for j in range(i + 1, n): | |
| # 1์ด๊ฐ ์ง๋ฌ์ผ๋ฏ๋ก ์๊ฐ์ ๋ํจ | |
| answer[i] += 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def solution(s): | |
| stack = [] | |
| for char in s: | |
| # ์คํ์ ๋ฌด์ธ๊ฐ ์๊ณ , ๋งจ ์ ๊ธ์๊ฐ ํ์ฌ ๊ธ์์ ๊ฐ๋ค๋ฉด? -> ์ง๊ฟ ๋ฐ๊ฒฌ! | |
| if stack and stack[-1] == char: | |
| stack.pop() | |
| # ๊ทธ ์ธ์ ๋ชจ๋ ๊ฒฝ์ฐ (์คํ์ด ๋น์๊ฑฐ๋, ๊ธ์๊ฐ ๋ค๋ฅด๊ฑฐ๋) -> ์ผ๋จ ์๊ธฐ | |
| else: | |
| stack.append(char) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def is_able(s): | |
| pairs = {')': '(', ']': '[', '}': '{'} | |
| stack = [] | |
| for current_s in s: | |
| # 1. ์ฌ๋ ๊ดํธ์ธ ๊ฒฝ์ฐ | |
| if current_s in pairs.values(): | |
| stack.append(current_s) | |
| # 2. ๋ซ๋ ๊ดํธ์ธ ๊ฒฝ์ฐ |
NewerOlder