[TIL 3일차] 데브코스 데이터엔지니어링

heering·2023년 4월 12일
0

TIL 3일차

학교에서 배웠던 자료구조 시간 그 자체다..! 한 학기 동안 배웠던걸 일주일만에 다시 복습하려니 빡세긴 하지만 구성이 넘 알차서 재밌다.

  • 양방향 연결리스트로 구현하는 큐
  • 환형큐
  • 우선순위 큐

트리

  • 이진 트리
  • 이진 탐색 트리
  • 전위순회, 중위순회, 후위순회
  • BFS

  • 최대 힙에서의 원소 삭제

프로그래머스 코딩테스트 연습

(Lv1 ~ Lv2) 아마 프로그래머스 홈페이지에는 공개되지 않은 문제인듯?

  • 예산 소팅
def solution(d, budget):
    answer = 0
    
    d.sort()
    
    for i in range(0, len(d)):
        if budget - d[i] >= 0:
            budget -= d[i]
            answer += 1
        else:
            break
    
    return answer
  • 나머지 한 점 -> count를 쓰면 뭔가 깔끔해질 것 같은데,,
def solution(v):
    answer = []

    dic_x = {}
    dic_y = {}
    
    for i in range(0, len(v)):
        if v[i][0] not in dic_x.keys():
            dic_x[v[i][0]] = 1
        else:
            dic_x[v[i][0]] += 1
        
        if v[i][1] not in dic_y.keys():
            dic_y[v[i][1]] = 1
        else:
            dic_y[v[i][1]] += 1
    
    
    rect_x = list(zip(dic_x.keys(), dic_x.values()))
    rect_y = list(zip(dic_y.keys(), dic_y.values()))
    
    for i in range(0, len(rect_x)):
        if rect_x[i][1] == 1:
            answer.append(rect_x[i][0])
    
    for i in range(0, len(rect_y)):
        if rect_y[i][1] == 1:
            answer.append(rect_y[i][0])
        
            
    return answer
  • 운송 트럭
def solution(max_weight, specs, names):
    answer = 1
    
    dic = {}
    for i in range(0, len(specs)):
        dic[specs[i][0]] = int(specs[i][1])
    
    
    sum_all = 0
    for i in range(0, len(names)):
        sum_all += dic[names[i]]
        if sum_all > max_weight:
            answer += 1
            sum_all = dic[names[i]]
            
    return answer
  • 기능개발
import math

def solution(progresses, speeds):
    answer = []
    
    days = []
    for i in range(0, len(progresses)):
        days.append(math.ceil((100 - progresses[i]) / speeds[i]))
    
    count = 0
    maximum = days[0]
    for i in range(0, len(days)): # 0부터 시작하는 아이디어
        if maximum < days[i]:
            answer.append(count)
            maximum = days[i]
            count = 0
            
        count += 1
    
    if count > 0:
        answer.append(count)
    
    return answer
  • 최솟값 만들기
def solution(A,B):
    answer = 0

    A.sort()
    B.sort(reverse=True)
    
    for i in range(0, len(A)):
        answer += (A[i] * B[i])

    return answer
  • 사탕 담기 -> count 쓰는 법 터득
from itertools import combinations

def solution(m, weights):
    answer = 0

    for i in range(len(weights)):
        comb = combinations(weights, i)
        answer += [sum(weight) for weight in comb].count(m)
    
    return answer

0개의 댓글