일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- 구현
- 백준 막대기
- BFS
- softeer
- leetcode 2405
- python 14503
- python 1259
- Python 20001
- 큐
- BOJ
- 백준 2309
- python 2309
- python 10989
- 개발자 취업
- Python
- leetcode
- 스택
- 코딩테스트 준비
- 백준 카드1
- til
- 99클럽
- 파이썬
- boj 2309
- python 10250
- 프로그래머스
- 항해99
- 백준
- 99항해
- 백준 팰린드롬수
- 일곱 난쟁이
- Today
- Total
목록전체 글 (66)
동까의 코딩
https://leetcode.com/problems/reordered-power-of-2/description/ import itertoolsclass Solution: def reorderedPowerOf2(self, n: int) -> bool: cnt = 0 answer = False n = str(n) num_list = [] for i in n: num_list.append(i) nCr = itertools.permutations(num_list, len(num_list)) num_list = [] nCr = list(nCr) for i in range(le..
https://leetcode.com/problems/top-k-frequent-elements/submissions/1294689495/ 정렬하여 카운트를 해주고, 많은 숫자를 보여한 숫자를 정답칸에 K만큼 저장해주고 반환하는 문제입니다. class Solution: def topKFrequent(self, nums: List[int], k: int) -> List[int]: cnt = {} cnt_list = [[] for _ in range(len(nums) + 1)] answer = [] for num in nums: cnt[num] = 1 + cnt.get(num, 0) for key, val in cnt.i..
https://leetcode.com/problems/sort-characters-by-frequency/description/ class Solution: def frequencySort(self, s: str) -> str: m = {} for c in s: if c not in m: m[c] = 1 else: m[c] += 1 li = sorted([(m[i], i) for i in m], reverse=True) res = [] for count, c in li: res.append(c * count) ..
https://leetcode.com/problems/minimum-suffix-flips/submissions/1291875785/ 오늘의 문제는 leetcode의 문자열 문제입니다. class Solution: def minFlips(self, target: str) -> int: acc=0 for i in range(len(target)): if target[i]=="0" and acc%2==0 or target[i]=="1" and acc%2==1: continue else: acc+=1 return acc
https://leetcode.com/problems/iterator-for-combination/submissions/1291059479/ class CombinationIterator: def __init__(self, characters: str, combinationLength: int): self.len = len(characters) self.characters = characters self.pointers = [i for i in range(combinationLength)] self.pointers[-1] -= 1 self.thres = [i for i in range(self.len - len(self.pointers)..
https://leetcode.com/problems/group-the-people-given-the-group-size-they-belong-to/ class Solution: def groupThePeople(self, groupSizes: List[int]) -> List[List[int]]: rst, dt = [], collections.defaultdict(list) for i, g in enumerate(groupSizes): dt[g].append(i) if len(dt[g]) == g: rst.append(dt[g]) dt[g] = [] return rst
https://leetcode.com/problems/find-the-original-array-of-prefix-xor/submissions/1289234381/ leetcode 문제사이트의 배열 문제입니다. class Solution: def findArray(self, pref: List[int]) -> List[int]: ans = [0] * len(pref) ans[0] = pref[0] for i in range(1, len(ans)): ans[i] = pref[i] ^ pref[i - 1] return ans
https://leetcode.com/problems/subrectangle-queries/ class SubrectangleQueries: def __init__(self, rectangle: List[List[int]]): self.rectangle = rectangle def updateSubrectangle(self, row1: int, col1: int, row2: int, col2: int, newValue: int) -> None: for i in range(row1, row2 + 1) : for j in range(col1, col2 + 1) : self.rectangle[i][j] = new..