본문 바로가기

Algorithm

(17)
[JAVA 알고리즘] 지폐 접기 ✅ 문제 https://school.programmers.co.kr/learn/courses/30/lessons/340199 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr ✅ 코드 class Solution { public int solution(int[] wallet, int[] bill) { int answer = 0; // 지갑의 작은/큰 값 int wSmall = Math.min(wallet[0], wallet[1]); int wLarge = Math.max(wallet[0], wallet[1]); int b0 = bill[0]; ..
[JAVA 알고리즘] 유연근무제 ✅ 문제 https://school.programmers.co.kr/learn/courses/30/lessons/388351 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr ✅ 코드 class Solution { // hhmm 형식의 정수를 분 단위로 바꿔주는 헬퍼 private int toMinutes(int hhmm) { int hour = hhmm / 100; int minute = hhmm % 100; return hour * 60 + minute; } public int solution(int[] schedules, int[][] timelogs..
[JAVA 알고리즘] 바탕화면 정리 ✅ 문제https://school.programmers.co.kr/learn/courses/30/lessons/161990 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr ✅ 코드 class Solution { public int[] solution(String[] wallpaper) { int minHigh = Integer.MAX_VALUE; int maxHigh = Integer.MIN_VALUE; int minWeight = Integer.MAX_VALUE; int maxWeight = Integer.MIN_VALUE; for (int i..
[JAVA 알고리즘] 폰켓몬 ✅ 문제https://school.programmers.co.kr/learn/courses/30/lessons/1845 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr.✅ 코드 import java.util.*;class Solution { public int solution(int[] nums) { int answer = 0; Set temp = new HashSet(); for (int s : nums) { temp.add(s); } int maxTypes = temp.size(); int maxPick ..
[알고리즘] 기본 정렬 알고리즘 (Sorting Algorithms) ✅ 정렬 알고리즘이란?정렬 알고리즘은 데이터 요소들을 특정 순서대로 정렬하는 알고리즘이다. 일반적으로 리스트나 배열 같은 데이터 구조에 저장된 요소들을 오름차순이나 내림차순 같은 순서로 재배열하는 데 사용된다. 선택 정렬 (Selection Sort)삽입 정렬 (Insertion Sort)버블 정렬 (Bubble Sort)합병 정렬 (Merge Sort)퀵 정렬, 퀵소트 (Quick Sort) ✅ 선택 정렬 (Selection Sort)선택 정렬은 배열에서 가장 작은(또는 가장 큰) 요소를 찾아서 리스트의 가장 앞, 또는 가장 뒤로 옮기고, 정렬되지 않은 나머지 리스트 부분에 같은 과정을 반복하여 전체 배열을 정렬하는 방식이다. 예시는 단순히 최댓값을 찾은 후 리스트의 뒤로 옮기는 과정을 반복하고 있다..
[SQL 알고리즘] FrontEnd 개발자 찾기 ✅ 문제https://school.programmers.co.kr/learn/courses/30/lessons/276035 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr ✅ 코드 SELECT D.ID, D.EMAIL, D.FIRST_NAME, D.LAST_NAMEFROM DEVELOPERS AS DWHERE EXISTS ( SELECT 1 FROM SKILLCODES S WHERE (D.SKILL_CODE & S.CODE) != 0 AND S.CATEGORY = 'Front End' )ORDER BY D.ID ;..
[SQL 알고리즘] 프로그래머스 -대장균들의 자식의 수 구하기 https://school.programmers.co.kr/learn/courses/30/lessons/299305 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr ✅ 문제대장균 개체의 ID(ID)와 자식의 수(CHILD_COUNT)를 출력하는 SQL 문을 작성해 주세요. 자식이 없다면 자식의 수는 0으로 출력해 주세요. 이때 결과는 개체의 ID에 대해 오름차순 정렬해 주세요. ✅ 나의 코드SELECT ID, (SELECT COUNT(ID) FROM ECOLI_DATA AS B WHERE A.ID = B.PARENT_ID ) A..
[SQL 알고리즘] SolvedSql - 배송 예정일 예측 성공과 실패 ✅ 문제https://solvesql.com/problems/estimated-delivery-date/ https://solvesql.com/problems/estimated-delivery-date/ solvesql.com ✅ 코드 select date(a.order_purchase_timestamp) as purchase_date,(select count(DISTINCT order_id) from olist_orders_dataset b where order_estimated_delivery_date > order_delivered_customer_date and date(a.order_purchase_timestamp) = date(b.order_purchase_timestamp)) as su..