전체 글 (31) 썸네일형 리스트형 7/7 코테 일지 #1654랜선 자르기처음에는 모든 전선을 모두 사용해야 하는 줄 알고 min(k_array)를 했으나 그럴 필요가 없다는 것을 깨닫고 max(k_array)를 하니 풀렸다.import sysk, n = map(int,sys.stdin.readline().rstrip().split(' '))k_array= []for _ in range(k): k_array.append(int(sys.stdin.readline().rstrip()))l, r = 1, max(k_array)ans = 0while (l= n : l = mid + 1 ans = mid elif sum NeetCode 18번 알고리즘 : BST Insert and Remove Insertion # Insert a new node and return the root of the BST.def insert(root, val): if not root: return TreeNode(val) if val > root.val: root.right = insert(root.right, val) elif val Removal0 or 1 Child 2 Children # Return the minimum value node of the BST.def minValueNode(root): curr = root while curr and curr.left: curr = curr.left return curr# Remo.. 7/6 코테 일지 (중요! set 자료형과 원소 검색, 배열 안 배열 sorting, sort key) set 자료형과 원소 검색10815 숫자 카드 해당 문제를 풀기 위해 binary search를 사용하였으며 통과하였다. 하지만 시간이 꽤나 오래 걸렸고 다른 코드들을 보아하니 나보다 훨씬 적게 걸린 제출들이 많이 보였다. import sysn = int(sys.stdin.readline().rstrip())n_array = list(map(int,sys.stdin.readline().rstrip().split(' ')))m = int(sys.stdin.readline().rstrip())m_array = list(map(int,sys.stdin.readline().rstrip().split(' ')))n_array.sort()ans = [0 for _ in range(len(m_array))]for .. 이전 1 2 3 4 5 6 7 ··· 11 다음