PROGRAMMERS 17677: [1차] 뉴스 클러스터링 Link : programmers.co.kr/learn/courses/30/lessons/17677 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 def intersection(list1, list2): stack = [] for i in list1: if i in list2: stack.append(i) list2.remove(i) return stack def union(list1, list2): return list1 + list2 def solution(str1, str2): str1 = str1.lower() str2 = str2.lower() data1 = list() d.. 2021. 1. 13. PROGRAMMERS 12973: 짝지어 제거하기 Link : programmers.co.kr/learn/courses/30/lessons/12973 Python 더보기 1 2 3 4 5 6 7 8 9 10 11 12 def solution(s): stack = [] for i in s: if len(stack) == 0: stack.append(i) else: if stack[-1] == i: stack.pop() else: stack.append(i) return 1 if len(stack) == 0 else 0 cs FeedBack cjw.git@gmail.com 2021. 1. 11. PROGRAMMERS 43163: 단어 변환 Link : programmers.co.kr/learn/courses/30/lessons/43163 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 def check(str1, str2): if len(str1) != len(str2): return False counter = 0 for i in range(len(str1)): if str1[i] != str2[i]: counter += 1 return True if counter == 1 else False def solution(begin, target, words): queue = [] queue.append((begin, 0)) while len(queue): d.. 2021. 1. 11. PROGRAMMERS 42746: 가장 큰 수 Link : programmers.co.kr/learn/courses/30/lessons/42746 Python 더보기 1 2 3 4 5 6 7 8 9 10 11 12 13 14 def solution(numbers): numbers = list(map(str, numbers)) for idx, val in enumerate(numbers): result = val for i in range(0, 5 - len(val)): result += val[i % len(val)] numbers[idx] = (val, result) numbers.sort(key=lambda x: x[1], reverse=True) result = '' for i in numbers: result += i[0] return str.. 2021. 1. 11. PROGRAMMERS 60057: 문자열 압축 Link : programmers.co.kr/learn/courses/30/lessons/60057 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 def sol(s, n): result = '' while len(s): counter = 1 for i in range(0, len(s), n): status = (s[0:n] == s[i + n:i + 2 * n]) if status: counter += 1 else: result += (str(counter) if counter > 1 else '') + s[0:n] s = s[counter * n:] break else: if counter .. 2021. 1. 11. 이전 1 ··· 4 5 6 7 8 9 10 ··· 17 다음