본문 바로가기

algorithm

(114)
[programmers] Java - Lv.0 짝수는 싫어요 문제 풀이 class Solution { public int[] solution(int n) { int[] answer = new int[(n + 1) / 2]; int cnt = 0; for(int i = 0; i
[programmers] Java - Lv.0 문자 반복 출력하기 문제 풀이 class Solution { public String solution(String my_string, int n) { String answer = ""; for(int i = 0; i < my_string.length(); i++) { for(int j = 0; j < n; j++) { answer += my_string.charAt(i); } } return answer; } }
[programmers] Java - Lv.0 배열 자르기 문제 풀이 class Solution { public int[] solution(int[] numbers, int num1, int num2) { int[] answer = new int[num2 - num1 + 1]; int cnt = 0; for(int i = num1; i
[programmers] MySQL - Lv.4 취소되지 않은 진료 예약 조회하기 (String, Date) 문제 풀이 SELECT b.apnt_no, a.pt_name, a.pt_no, b.mcdp_cd, c.dr_name, b.apnt_ymd from patient a join appointment b on a.pt_no = b.pt_no join doctor c on b.mddr_id = c.dr_id where b.mcdp_cd = 'CS' and b.apnt_ymd like '2022-04-13%' and b.apnt_cncl_yn = 'N' order by b.apnt_ymd
[programmers] Java - Lv.0 점의 위치 구하기 문제 풀이 class Solution { public int solution(int[] dot) { if(dot[0] > 0 && dot[1] > 0) { return 1; } else if(dot[0] 0) { return 2; } else if(dot[0] < 0 && dot[1] < 0) { return 3; } else { return 4; } } }
[programmers] MySQL - Lv.4 년, 월, 성별 별 상품 구매 회원 수 구하기 (group by) 문제 풀이 select b.year, b.month, a.gender, count(distinct(a.user_id)) users from user_info a join (select user_id, year(sales_date) year, month(sales_date) month from online_sale) b on a.user_id = b.user_id where a.gender is not null group by b.year, b.month, a.gender order by b.year, b.month, a.gender
[HackerRank] MySQL - Occupations 문제 Pivot the Occupation column in OCCUPATIONS so that each Name is sorted alphabetically and displayed underneath its corresponding Occupation. The output column headers should be Doctor, Professor, Singer, and Actor, respectively. Note: Print NULL when there are no more names corresponding to an occupation. Input Format The OCCUPATIONS table is described as follows: Occupation will only contain..
[programmers] Java - Lv.0 배열 원소의 길이 문제 풀이 class Solution { public int[] solution(String[] strlist) { int[] answer = new int[strlist.length]; for(int i = 0; i < strlist.length; i++) { answer[i] = strlist[i].length(); } return answer; } }