본문 바로가기

Programmers/Level3

(44)
오랜 기간 보호한 동물(2) 1 2 3 4 5 6 select i.animal_id, i.name from animal_ins i inner join animal_outs o on i.animal_id = o.animal_id where o.datetime - i.datetime >= 0 order by o.datetime - i.datetime desc limit 2; Colored by Color Scripter cs 1. join을 이용하여 입양 간 동물에 대해서만 검사한다. 2. 입양 간 날짜 - 보호한 날짜가 0이상인 정상적인 데이터를 필터링한다. 3. 내림차순으로 정렬한다. 4. 출력한다.
오랜 기간 보호한 동물(1) 1 2 3 4 select name, datetime from animal_ins where animal_id not in (select animal_id from animal_outs) order by datetime limit 3; Colored by Color Scripter cs 1. 입양 간 동물을 불러온다. 2. not in을 이용하여 보호소에 있는 동물 중 입양 간 동물들의 아이디에 포함되지 않은 아이디를 검색한다. 3. 정렬 후 출력
없어진 기록 찾기 1 select animal_id, name from animal_outs where animal_id not in (select animal_id from animal_ins); cs not in을 사용하여 간단히 해결하였다.
다단계 칫솔 판매 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647import java.util.*;class Solution { static HashMap map = new HashMap(); static ArrayList list = new ArrayList(); static void moneyCal(String seller, int money) { Persons person = list.get(map.get(seller)); int remain = (int) (money * 0.1); person.profit += money - remain; // 추천인이 없거나 배분 금액이 없을 경우 종료 if(person.re..
네트워크 1234567891011121314151617181920212223242526class Solution { static boolean visited[]; public static void DFS(int pos, int n, int[][] computers) { if(visited[pos]) return; visited[pos] = true; for(int i=0;i
헤비 유저가 소유한 장소 1 2 select id, name, host_id from places where host_id in (select host_id from places group by host_id having count(*) >= 2) order by id; cs 서브쿼리를 사용하는 문제이다.
있었는데요 없었습니다 1 2 select i.animal_id, i.name from animal_ins i, animal_outs o where i.animal_id = o.animal_id and i.datetime > o.datetime order by i.datetime; cs join 및 시간을 비교하는 구문을 사용하였다.
줄 서는 방법 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 import java.util.*; class Solution { static long Factorial(int n) { if(n == 1) return 1; return n * Factorial(n - 1); } public int[] solution(int n, long k) { int[] answer = new int[n]; ArrayList persons = new ArrayList(); for(int i=1;i 0) { long nextNum = Factorial(n) / n; int idx = (int) (k / nextNum); answer[pos] = person..