일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- focalloss
- 네이버AI부스트캠프
- l2penalty
- cmp_to_key
- objectdetection
- autograd
- 정렬
- fasterRCNN
- 중복순열
- 자료구조끝판왕문제
- layernormalization
- labelsmoothing
- labelsmoothingloss
- 우선순위큐
- Optimizer
- Focal Loss
- mmdetectionv3
- clibration
- ComputerVision
- ImageClassification
- pytorch
- 네이버 ai 부스트캠프
- f1loss
- 밑바닥부터 시작하는 딥러닝
- BatchNormalization
- DataAugmentation
- noiserobustness
- 프로그래머스
- 힙
- inference
- Today
- Total
목록Coding test (18)
HealthyAI

from collections import defaultdict import math def solution(fees, records): answer = [] basic_min, basic_won = fees[0], fees[1] unit_min, unit_won = fees[2], fees[3] dic = defaultdict(int) time = defaultdict(int) for rec in records: t, car, move = rec.split() if move == 'IN': dic[car] = int(t.split(':')[0]) * 60 + int(t.split(':')[1]) elif move == 'OUT': dic[car] = int(t.split(':')[0]) * 60 + i..

~ 개 이상 인 값들이 ~개 이상 있다. 라는 표현이 나온다면 정렬을 하고 인덱스 값을 붙이면서 풀 수 있을 것 같다. def solution(citations): stack = [] citations.sort(reverse = True) for i, c in enumerate(citations, start = 1): stack.append(min(i,c)) return max(stack)

처음에는 itertools의 permutations 함수를 사용해서 풀었는데 런타임 초과 문제로 다른 방법을 찾아야 했다. from itertools import permutations def solution(numbers): answer = '' stack = [] numbers = [str(i) for i in numbers] for p in permutations(numbers, len(numbers)): stack.append(int(''.join(p))) return str(max(stack)) 이 과정에서 functools 모듈의 cmp_to_key 함수를 알게 되었다. 두 문자의 결합을 비교하여 1,0 반환 시 위치를 그대로 하고 -1 반환 시 위치를 바꿔준다. from functools i..

max_heap과 min_heap을 동시에 저장 하면서 비교 해야 됐던 이중 우선 순위 큐 문제이다. 처음에는 최댓값을 구하는 함수로 풀었었는데 연산 횟수가 늘고, 자료가 증가 할 수록 연산의 과부화가 생겨 우선순위 큐를 선택하여 다시 풀이법을 공부하였다. from heapq import heappush, heappop def solution(operations): min_heap = [] max_heap = [] for op in operations: if op == 'D 1': if max_heap: heappop(max_heap) if not max_heap or -max_heap[0] < min_heap[0]: min_heap, max_heap = [], [] elif op == 'D -1': i..

데이터를 다룰 때 많은 가르침을 줬던 문제이다. defaultdict를 사용하여 간단하게 genre가 key인 두개의 딕셔너리를 만든다. 조건을 만족 시키는 순서 대로 정렬 해주면서 답을 저장 한다. from collections import defaultdict def solution(genres, plays): answer = [] genre_tot = defaultdict(int) genre_plays = defaultdict(list) for i, (g, p) in enumerate(zip(genres, plays)): # {g1:p1, g2:p2 ....} genre_tot[g] += p # {g1:[(i1,p1), (i2,p2)], g2: [(i3,p3),(i4,p4)], ... } genre..

defaultdict 는 데이터를 다룰 때 내 최애 함수이다. 이 문제 에서는 종류별로 안입는 경우들도 포함 시켜서 곱해 준 다음에 모든 종류들을 동시에 안입는 경우 1을 빼주면 완성된다. from collections import defaultdict def solution(clothes): answer = 1 clothes_dic = defaultdict(int) for cloth in clothes: clothes_dic[cloth[1]] += 1 for cnt in clothes_dic.values(): answer *= cnt+1 return answer - 1

def solution(phone_book): answer = True phone_book.sort() for i in range(len(phone_book)-1): if phone_book[i+1].startswith(phone_book[i]): return False return answer

카운터 끼리 뺄수 있다는 것 명심 하자! from collections import Counter def solution(participant, completion): not_complete = Counter(participant) - Counter(completion) answer = list(not_complete.keys())[0] return answer

나는 이렇게 풀었다. def solution(nums): answer = 0 set_n = set(nums) if len(set_n) len(nums)//2: answer = len(nums)//2 return answer 다른 사람은 이렇게 줄여 놨다. 클래스~ 따라간다 def solution(nums): return min(len(set(nums)), len(nums)//2)

구현 하기에 가장 어려웠던 문제였던 것 같다. 문제에 처음 방향이 오른쪽이라고 명시되어 있었던 부분이 풀이 초기에 매우 애매 하였다. 그래서 해답을 보고 오른쪽 방향이 뱀 기준 오른쪽 방향이 아니였던 것을 알게 되었다. 해답의 도움을 받아 코드를 작성하고 5번 반복 풀이 했다... 너무나 어렵디 from collections import deque n = int(input()) k = int(input()) field = [[0] * (n+1) for _ in range(n+1)] for _ in range(k): a, b = map(int, input().split()) field[a][b] = 1 l = int(input()) info = [] for i in range(l): c, d = input..