ํ•ญํ•ด99

๋ฌธ์ œ๋ฆฟ์ฝ”๋“œ 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(..
๋ฌธ์ œ๋ฐฑ์ค€ ๊ทธ๋ฆผ https://www.acmicpc.net/problem/1926 ์ฝ”๋“œfrom collections import dequen, m = map(int, input().split()) # ์„ธ๋กœ, ๊ฐ€๋กœpaper = [list(map(int, input().split())) for _ in range(n)]visit = [[False for _ in range(m)] for _ in range(n)] # ๋ฐฉ๋ฌธ ๊ธฐ๋ก์šฉmaxi = 0picture_count = 0for i in range(n): # ์„ธ๋กœ์ขŒํ‘œ for j in range(m): # ๊ฐ€๋กœ์ขŒํ‘œ if paper[i][j] == 1 and visit[i][j] == False: # ๊ทธ๋ฆผ์ด๊ณ , ๋ฐฉ๋ฌธํ•œ์  ์—†๋‹ค๋ฉด ..
๋ฌธ์ œ๋ฐฑ์ค€ ์•”ํ˜ธ ๋งŒ๋“ค๊ธฐ https://www.acmicpc.net/problem/1759 ์ฝ”๋“œl, c = map(int, input().split()) # ์•”ํ˜ธ๊ธธ์ด, ํ›„๋ณด ๋ฌธ์ž ๊ฐœ์ˆ˜letters = sorted(list(map(str, input().split()))) # ํ›„๋ณด ๋ฌธ์žarr = []# ๋ชจ์Œ ์„ธ๋Š” ํ•จ์ˆ˜def count_vowel(lst): return lst.count('a') + lst.count('e') + lst.count('i') + lst.count('o') + lst.count('u')def recur(idx): if len(arr) == l: # ๋ชจ์Œ ํ•œ๊ฐœ์ด์ƒ, ์ž์Œ ๋‘๊ฐœ ์ด์ƒ์ด๋ฉด if count_vowel(arr) >= 1 and l - c..
๋ฌธ์ œ๋ฐฑ์ค€ ๋ฆฌ๋ชจ์ปจ https://www.acmicpc.net/problem/1107 ์ฝ”๋“œtarget = int(input())m = int(input())if m != 0: broken = list(map(int, input().split()))else: broken = []count = abs(100 - target)for num in range(1000000 + 1): for n in str(num): if int(n) in broken: break else: count = min(count, len(str(num)) + abs(num - target))print(count) ํ’€์ดtarget = int(input())m = int(inp..
๋ฌธ์ œ๋ฐฑ์ค€ ๊ฐ์†Œํ•˜๋Š” ์ˆ˜ https://www.acmicpc.net/problem/1038 ์ฝ”๋“œn = int(input())if n > 1022: print(-1)else: num = [] ans = [] def check(i): global num if len(num) == 1: return True if num[-2] > i: return True def dfs(depth): global num for i in range(10): num.append(i) if check(i): dfs(depth + 1) ..
๋•ก๋•ก๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป
'ํ•ญํ•ด99' ํƒœ๊ทธ์˜ ๊ธ€ ๋ชฉ๋ก