본문 바로가기
PROGRAMMERS 64065: 튜플 Link : https://programmers.co.kr/learn/courses/30/lessons/64065 Python 더보기 1 2 3 4 5 6 7 8 9 10 11 def solution(s): s = s.replace(',', ' ').replace('{', ' ').replace('}', ' ') result = list(map(int, s.split())) data = dict() for i in result: if i not in data: data[i] = 0 data[i] += 1 answer = list(data.items()) answer.sort(key=lambda x: x[1], reverse=True) return [i[0] for i in answer] cs FeedBa.. 2021. 12. 31.
PROGRAMMERS 77486: 다단계 칫솔 판매 Link : https://programmers.co.kr/learn/courses/30/lessons/77486 Python 더보기 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 31 32 33 34 35 36 37 38 39 class Node: def __init__(self, name): self.name = name self.amount = 0 self.parent = None def __str__(self): return self.name + " : " + str(self.amount) def traceNode(person: Node, amount): if amount 2021. 12. 31.
PROGRAMMERS 72411: 메뉴 리뉴얼 Link : https://programmers.co.kr/learn/courses/30/lessons/72411 Python 더보기 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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 def DFS(arr, deapth, items, length): """ 특정 길이의 모든 조합을 문자열로 반환해주는 함수 :param arr: 현재 리스트 :param deapth: 현재 길이 :param items: 조합 할 목록들 :param length: 조합 길이 :retu.. 2021. 12. 31.
LEETCODE 287: Find the Duplicate Number Link : https://leetcode.com/problems/find-the-duplicate-number/solution/ Python 더보기 1 2 3 4 5 6 7 8 class Solution: def findDuplicate(self, nums: list[int]) -> int: arr = dict() for i in nums: if i not in arr: arr[i] = True else: return i cs FeedBack cjw.git@gmail.com 2021. 8. 5.
LEETCODE 128. Longest Consecutive Sequence Link : https://leetcode.com/problems/longest-consecutive-sequence/ Python 더보기 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 class Solution: def DFS(self, start, length): if start not in self.memory or self.memory[start]: return length self.memory[start] = True return self.DFS(start + 1, length + 1) def longestConsecutive(self, nums: list[int]) -> int: self.memory = dict() for n in num.. 2021. 8. 5.