ํ•ญํ•ด99

๋ฌธ์ œํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์†Œ์ˆ˜์ฐพ๊ธฐhttps://school.programmers.co.kr/learn/courses/30/lessons/42839 ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”.programmers.co.kr  ์ฝ”๋“œimport itertoolsdef sosu(num): if num == 0 or num == 1: return False for i in range(2, int(num ** 0.5) + 1): if num % i == 0: return False return Truedef solution(n): answe..
๋ฌธ์ œ๋ฐฑ์ค€  ๋‰ด์Šค ์ „ํ•˜๊ธฐ https://www.acmicpc.net/problem/1135 ์ฝ”๋“œn = int(input())parent_list = list(map(int, input().split()))child_list = [list() for _ in range(n)]for child in range(1, n) : parent = parent_list[child] child_list[parent].append(child)def dfs(node) : if not child_list[node] : return 0 result = list() for child in child_list[node] : result.append(dfs(child)) result.sort( reverse =..
๋ฌธ์ œ๋ฐฑ์ค€ 1927 ์ตœ์†Œ ํž™ https://www.acmicpc.net/problem/1927๋ฐฑ์ค€ 11279 ์ตœ๋Œ€ ํž™ https://www.acmicpc.net/problem/11279 ์ตœ์†Œ ํž™ ์ฒ˜์Œ ์ฝ”๋“œ (์‹œ๊ฐ„์ดˆ๊ณผ)๋ฐฐ์—ด์—์„œ min()์„ ์ด์šฉํ•˜์—ฌ ์ตœ์†Œ๊ฐ’์„ ์ฐพ์•˜๋‹ค.n = int(input())x = []for _ in range(n):    num = int(input())    if num == 0:        if x:            print(min(x))            x.remove(min(x))        else:            print(0)    else:        x.append(num) ์ตœ์†Œ ํž™ ์ฝ”๋“œimport sysimport heapqn = int(input()..
99ํด๋Ÿฝ์ด๋ž€?์ฝ”๋”ฉํ…Œ์ŠคํŠธ ํ•ฉ๊ฒฉ๋ฅ ์„ ๋†’์ด๊ธฐ ์œ„ํ•ด ํ•จ๊ป˜ ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ๋ฌธ์ œ๋ฅผ ํ‘ธ๋Š” ํ•ญํ•ด99 ์ฃผ์ตœ ์Šคํ„ฐ๋”” ์ด๋‹ค.  99ํด๋Ÿฝ ์ง„ํ–‰ ๊ณผ์ •์ž์‹ ์˜ ์ˆ˜์ค€์— ๋”ฐ๋ผ ๋น„๊ธฐ๋„ˆ, ๋ฏธ๋“ค๋Ÿฌ, ์ฑŒ๋ฆฐ์ € ๋ ˆ๋ฒจ๋กœ ๋‚˜๋‰œ๋‹ค. ๋‚˜๋Š” ํŒŒ์ด์ฌ ๋ฏธ๋“ค๋Ÿฌ๋กœ ์ฐธ๊ฐ€ํ•˜์˜€๋‹ค.๋น„๊ธฐ๋„ˆ๋Š” ๋ฐฑ์ค€ ๋ธŒ๋ก ์ฆˆ ๋˜๋Š” ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค 1๋ ˆ๋ฒจ ์ˆ˜์ค€์ด๋‹ค.๋ฏธ๋“ค๋Ÿฌ๋Š” ๋ฐฑ์ค€ ์‹ค๋ฒ„ ๋˜๋Š” ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค 2๋ ˆ๋ฒจ ์ˆ˜์ค€์ด๋‹ค.์ฑŒ๋ฆฐ์ €๋Š” ๋ฐฑ์ค€ ๊ณจ๋“œ ๋˜๋Š” ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค 3๋ ˆ๋ฒจ ์ˆ˜์ค€์ด๋‹ค.๋งค์ผ ์˜ค์ „ 11์‹œ์— ๋‹จํ†ก๋ฐฉ ๋˜๋Š” ํ•™์Šต๊ณต๊ฐ„ ์‚ฌ์ดํŠธ์— ์ž์‹ ์ด ์„ ํ…ํ•œ ๋ ˆ๋ฒจ์— ๋งž๋Š” ๋ฌธ์ œ๋ฅผ ํ•˜๋‚˜์”ฉ ๋‚ด์ฃผ์—ˆ๋‹ค.๋ฌธ์ œ๋ฅผ ํ’€๊ฑฐ๋‚˜ ๋ชปํ’€์–ด๋„ ํ‘ผ ์‹œ๋„๊ฐ€ ์žˆ๋Š” ํ™”๋ฉด์„ ์บก์ณํ•ด์„œ ์ธ์ฆํ•˜๋ฉด ๊ทธ๋‚ ์˜ ์ถœ์„์ฒดํฌ๋Š” ์™„๋ฃŒ๋‹ค.TIL์„ ์˜ฌ๋ ค์„œ ๋งํฌ๋ฅผ ์˜ฌ๋ ค์„œ ์ธ์ฆํ•œ๋‹ค.TIL์€ ์„ ํƒ์ด์ง€๋งŒ ๋งค์ผ ๊พธ์ค€ํžˆ ์—ฐ์†์œผ๋กœ ์ธ์ฆํ•˜๋ฉด ๋ณด์ƒ์ด ์ฃผ์–ด์ง„๋‹ค.์›”/๋ชฉ์€ ์ •๊ธฐ์Šคํ„ฐ๋”” ๋‚ ๋กœ, ๊ฒŒ๋”ํƒ€์šด์ด๋ผ๋Š”..
๋ฌธ์ œ๋ฆฟ์ฝ”๋“œ 1338. Reduce Array Size To The Halfhttps://leetcode.com/problems/reduce-array-size-to-the-half/description/ ์ฝ”๋“œclass Solution(object): def minSetSize(self, arr): answer = 0 count_num = {} for num in arr: if num not in count_num.keys(): count_num[num] = 1 else: count_num[num] += 1 values = sorted(list(..
๋ฌธ์ œ๋ฆฟ์ฝ”๋“œ 1845. Seat Reservation Managerhttps://leetcode.com/problems/seat-reservation-manager/  ์ฝ”๋“œimport heapqclass SeatManager: def __init__(self, n): self.can_reserve = list(range(1, n + 1)) heapq.heapify(self.can_reserve) def reserve(self): return heapq.heappop(self.can_reserve) def unreserve(self, seatNumber): heapq.heappush(self.can_reserve, seatNumber)..
๋ฌธ์ œ๋ฆฟ์ฝ”๋“œ 921. Minimum Add to Make Parentheses Valishttps://leetcode.com/problems/minimum-add-to-make-parentheses-valid/ ์ฝ”๋“œclass Solution(object): def minAddToMakeValid(self, s): s = deque(s) stack = [] item = s.popleft() stack.append(item) while s: item = s.popleft() if not stack: stack.append(item) else: ..
๋ฌธ์ œ2390. Removing Stars From a String https://leetcode.com/problems/removing-stars-from-a-string/ ์ฝ”๋“œclass Solution(object): def removeStars(self, s): s = list(s) while '*' in s: for i in range(len(s)-1): if s[i + 1] == '*': s.pop(i+1) s.pop(i) break return ''.join(s) ํ’€์ดs = list(s)๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ๋ฐ›์€ ๋ฌธ์ž..
๋ฌธ์ œ๋ฆฟ์ฝ”๋“œ 1823. Find the Winner of the Circular Gamehttps://leetcode.com/problems/find-the-winner-of-the-circular-game/solutions/ ์ฝ”๋“œclass Solution: def findTheWinner(self, n: int, k: int) -> int: circle = [i for i in range(1, n+1)] count = 1 turn = 0 while len(circle) != 1: if count == k: circle.pop(turn) count = 1 ..
๋ฌธ์ œ๋ฐฑ์ค€ ๊ฑธ๊ทธ๋ฃน ๋งˆ์Šคํ„ฐ ์ค€์„์ด https://www.acmicpc.net/problem/16165 ์ฝ”๋“œn, m = map(int, input().split()) # ๊ฑธ๊ทธ๋ฃน์˜ ์ˆ˜, ๋งžํ˜€์•ผ ํ•  ๋ฌธ์ œ์˜ ์ˆ˜idol_dic = {}for _ in range(n): team_name = input() team_member_num = int(input()) team_member = [] for _ in range(team_member_num): team_member.append(input()) idol_dic[team_name] = team_memberfor _ in range(m): quiz = input() quiz_type = int(input()) ..
๋ฌธ์ œ๋ฐฑ์ค€ ์žƒ์–ด๋ฒ„๋ฆฐ ๊ด„ํ˜ธ https://www.acmicpc.net/problem/1541 ์ฝ”๋“œformular = list(input())formular.append('-')have_to_sum = []have_to_sub = []operand = ''for letter in formular: if letter != '+' and letter != '-': operand += letter elif letter == '+': have_to_sum.append(int(operand)) operand = '' elif letter == '-': have_to_sum.append(int(operand)) have_to_sub.appen..
๋ฌธ์ œ๋ฐฑ์ค€ ์ˆ˜ ์ฐพ๊ธฐ https://www.acmicpc.net/problem/1920 ์ฝ”๋“œn = int(input())arr = sorted(list(map(int, input().split())))m = int(input())targets = list(map(int, input().split()))for target in targets: answer = 0 # ์ด๋ถ„ํƒ์ƒ‰ s = 0 e = n - 1 while s target: # ๋‹ค์šด? e = mid - 1 else: # ์—…? s = mid + 1 print(answer) ํ’€์ดn = int(input())arr = sorted(list(map(int, input(..
๋•ก๋•ก๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป
'ํ•ญํ•ด99' ํƒœ๊ทธ์˜ ๊ธ€ ๋ชฉ๋ก