일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 분할정복
- 그리디
- 해시
- MST
- 자료구조
- 시뮬레이션
- DP
- 다이나믹 프로그래밍
- 크루스칼
- 다이나믹프로그래밍
- 재귀
- 그래프 이론
- 백트래킹
- 다시
- 트리
- BFS
- 브루트포스
- 플로이드-워셜
- 우선순위큐
- 그래프 탐색
- 서브쿼리
- 누적합
- 투포인터
- 다익스트라
- 수학
- DFS
- 에라토스테네스의 체
- GROUP BY
- 구현
- join
- Today
- Total
목록전공/프로그래머스 (34)
기록하고 까먹지 말기

날짜 : 2023. 10. 01 사용 언어 : python 문제 코드 from collections import deque def solution(n, wires): def bfs(idx): queue = deque() queue.append(1) visited = [False] * (n + 1) visited[1] = True cnt = 0 while queue: now = queue.popleft() cnt += 1 for i in range(len(wires)): if i == idx: continue # 사용 불가능한 와이어 if now in wires[i]: # 방문 x, 경로에 있는 경우 if now == wires[i][0] and not visited[wires[i][1]]: visited..

날짜 : 2023. 10. 01 사용 언어 : oracle 문제 코드 -- 7월 아이스크림 총 주문량과 상반기의 아이스크림 총 주문량을 더한 값이 큰 순서대로 상위 3개의 맛을 조회 select flavor from ( select a.flavor, a.total_order + b.total_order from first_half a join ( select flavor, sum(total_order) as total_order from july group by flavor ) b on a.flavor = b.flavor order by a.total_order + b.total_order desc ) where rownum < 4 ; 풀이 - july 테이블의 flavor는 first_half 테이블의..

날짜 : 2023. 10. 01 사용 언어 : oracle 문제 코드 -- 입양을 간 동물 중, 보호 기간이 가장 길었던 동물 두 마리의 아이디와 이름을 조회하는 SQL문 -- 결과는 보호 기간이 긴 순으로 조회 select * from ( select a.animal_id, a.name -- 아이디, 이름 출력 from animal_ins a join animal_outs b on a.animal_id = b.animal_id order by (b.datetime - a.datetime + 1) desc -- 보호기간이 긴 순으로 정렬 ) where rownum < 3 ; 풀이 - 보호기간을 계산한 다음, 해당 데이터를 내림차순으로 정렬하여 서브쿼리를 작성한다. - 그 다음 해당 테이블을 토대로 2개 ..

날짜 : 2023. 10. 01 사용 언어 : oracle 문제 코드 -- 중성화된 동물은 SEX_UPON_INTAKE 컬럼에 'Neutered' 또는 'Spayed'라는 단어 -- 동물의 아이디와 이름, 중성화 여부를 아이디 순으로 조회하는 SQL문 -- 중성화가 되어있다면 'O', 아니라면 'X'라고 표시 select animal_id, name, case when sex_upon_intake like 'Neutered%' then 'O' -- 중성화 조건 when sex_upon_intake like 'Spayed%' then 'O' else 'X' end as "중성화" from animal_ins order by animal_id asc -- 아이디 순으로 조회 ; 풀이 - 중성화가 되어있는 경..

날짜 : 2023. 10. 01 사용 언어 : oracle 문제 코드 -- 평균 대여 기간이 7일 이상인 자동차들의 자동차 ID와 평균 대여 기간(컬럼명: AVERAGE_DURATION) -- 평균 대여 기간은 소수점 두번째 자리에서 반올림 -- 결과는 평균 대여 기간을 기준으로 내림차순 정렬해주시고, -- 평균 대여 기간이 같으면 자동차 ID를 기준으로 내림차순 정렬 select car_id, round(avg(end_date - start_date + 1), 1) as average_duration from car_rental_company_rental_history group by car_id having round(avg(end_date - start_date + 1), 1) >= 7 order ..

날짜 : 2023. 09. 28 사용 언어 : python 문제 코드 from collections import deque def solution(graph): n, m = len(graph), len(graph[0]) for i in range(n): for j in range(m): if graph[i][j] == 1: graph[i][j] = 0 else: graph[i][j] = 1 answer = 0 queue = deque() queue.append([0, 0]) dx = [0, 0, 1, -1] dy = [1, -1, 0, 0] while queue: x, y = queue.popleft() if x == (n-1) and y == (m-1): return graph[x][y] + 1 for..

날짜 : 2023. 09. 28 사용 언어 : oracle 문제 코드 -- 완료된 중고 거래의 총금액이 70만 원 이상인 사람의 회원 ID, 닉네임, 총거래금액을 조회 -- 결과는 총거래금액을 기준으로 오름차순 정렬 select b.user_id, b.nickname, sum(a.price) as total_sales from used_goods_board a join used_goods_user b on a.writer_id = b.user_id where a.status = 'DONE' group by b.user_id, b.nickname having sum(a.price) >= 700000 order by total_sales asc; 풀이 - 중고거래 게시물과 중고거래 사이트 유저간 각각 wri..

날짜 : 2023. 09. 26 사용 언어 : python 문제 코드 시간초과 코드 def solution(n): nums = [1, 2, 4] res = [1] cnt = 0 def carry(idx): if idx == -1: res.insert(0, 1) return if res[idx] == 1: res[idx] = 2 elif res[idx] == 2: res[idx] = 4 else: res[idx] = 1 carry(idx-1) return while True: cnt += 1 if cnt == n: break idx = len(res) - 1 if res[idx] == 1: res[idx] = 2 continue elif res[idx] == 2: res[idx] = 4 continue e..