목록전체 글 (280)
susinlee 님의 블로그
[문제]https://school.programmers.co.kr/learn/courses/30/lessons/161990 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr [풀이]1. 드래그의 시작점과 끝점의 규칙을 찾는다.2. 드래그 시작점(lux, luy) 에서 lux는 파일 처음 나오는 행, luy는 파일이 처음 나오는 열이 된다.3. 드래그 끝점(rdx, rdy) 에서 rdx는 (파일이 존재하는 마지막 행 + 1), rdy는 (파일이 존재하는 마지막 열 + 1) 이 된다.4. 격자판을 완전탐색하면서 '#' 문자가 나오면 행과 열을 저장한다.5. min, max 함수를 이용해서 해당 값들을 구해준..
[문제]https://leetcode.com/problems/managers-with-at-least-5-direct-reports/description/ [풀이]Pandasimport pandas as pddef find_managers(employee: pd.DataFrame) -> pd.DataFrame: # manager = employee.groupby('managerId', as_index=False).size() # merged = manager.merge(employee, left_on='managerId', right_on='id') # return merged[merged['size']>=5][['name']] managers = employee.groupby('..
[문제]https://school.programmers.co.kr/learn/courses/30/lessons/118666 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr [풀이] 1. 딕셔너리를 통해 각 유형을 key로 해서 점수를 구해준다.2. 각 지표별로 타입을 가져오고, 해당 타입을 key로 하여 점수를 가져온다.3. 점수를 비교해서 성격 유형을 선택한다. 점수가 같을 때에는 사전순으로 가져오게끔 한다. from collections import defaultdictdef solution(survey, choices): person_type = defaultdict(int) answer..
[문제]https://leetcode.com/problems/students-and-examinations/description/?source=submission-ac [풀이]cross로 조인한 테이블과 미리 집계한 테이블을 이어 붙일 생각을 할 수 있어야 풀 수 있는 문제다.판다스로 문제를 풀 때는 테이블을 무작정 이을 생각이 아니라 처리를 먼저 한 다음에 붙일 줄 알아야 한다. Pandasimport pandas as pddef students_and_examinations(students: pd.DataFrame, subjects: pd.DataFrame, examinations: pd.DataFrame) -> pd.DataFrame: merged = pd.merge(students, subj..
[문제]https://leetcode.com/problems/employee-bonus/description/ [풀이] Pandasimport pandas as pddef employee_bonus(employee: pd.DataFrame, bonus: pd.DataFrame) -> pd.DataFrame: merged = pd.merge(employee, bonus, on='empId', how='left') cond1 = merged['bonus'].isna() cond2 = merged['bonus'] SQLselect name, bonusfrom Employee eleft join Bonus b ON e.empId = b.empIdwhere ifnull(bonu..
[문제]https://school.programmers.co.kr/learn/courses/30/lessons/133502 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr [풀이]1. 재료를 하나씩 꺼내와서 리스트 안에 넣고2. 끝에 4개 부분만 가져와서 [1, 2, 3, 1]과 같은지 확인 한 뒤3. 같으면 끝에 4개 부분을 지워주고 카운트를 1 증가시킨다 def solution(ingredient): food = [] cnt = 0 for z in ingredient: food.append(z) if food[-4:] == [1, 2, 3..

https://leetcode.com/problems/average-time-of-process-per-machine/description/ [문제]There is a factory website that has several machines each running the same number of processes. Write a solution to find the average time each machine takes to complete a process.The time to complete a process is the 'end' timestamp minus the 'start' timestamp. The average time is calculated by the total time to c..
https://leetcode.com/problems/rising-temperature/description/ [문제] Write a solution to find all dates' id with higher temperatures compared to its previous dates (yesterday).Return the result table in any order.The result format is in the following example. 1. diff() 함수는 연속된 행의 값의 차이를 계산하는 함수. 즉 이전 행과의 현재 행의 차이를 계산→ 현재행 값 - 이전행 값 Pandasimport pandas as pddef rising_temperature(weather: pd.DataFr..