๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

์˜ค๋ธ”์™„5

[Java / ๋ฐฑ์ค€ ] 12851. ์ˆจ๋ฐ”๊ผญ์งˆ ๋ฌธ์ œ๋งํฌ: https://www.acmicpc.net/problem/12851ํƒœ๊ทธ: bfs ํ’€์ด ์ˆจ๋ฐ”๊ผญ์งˆ ๋ฌธ์ œ์™€ ๋™์ผํ•˜์ง€๋งŒ, ๋‹ค๋ฅธ ์ ์ด ์žˆ๋‹ค๋ฉด ์ด๋ฏธ ๋ฐฉ๋ฌธํ•œ ์ง€์ ๋„ ์žฌ๋ฐฉ๋ฌธ์ด ๊ฐ€๋Šฅํ•˜๋„๋ก ํ•ด์•ผํ•œ๋‹ค๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.์žฌ๋ฐฉ๋ฌธ์ด ๊ฐ€๋Šฅํ•œ ๊ธฐ์ค€์€ ์ด์ „์— ๋ฐฉ๋ฌธํ–ˆ๋˜ ์‹œ๊ฐ„๊ณผ ๋‹ค์‹œ ๋ฐฉ๋ฌธํ•˜๋ ค๊ณ  ํ• ๋•Œ์˜ ๋„๋‹ฌ ์‹œ๊ฐ„์ด ๊ฐ™์„ ๋•Œ์ž…๋‹ˆ๋‹ค.๋‹ค์‹œ ๋ฐฉ๋ฌธํ•˜๋ ค๊ณ  ํ• ๋•Œ, ์ด์ „์— ๋„๋‹ฌํ–ˆ๋˜ ์‹œ๊ฐ„๋ณด๋‹ค ํฌ๋‹ค๋ฉด, K์— ๋„๋‹ฌํ–ˆ์„ ๋•Œ ์ตœ๋‹จ ์‹œ๊ฐ„์ด ๋  ๊ฐ€๋Šฅ์„ฑ์ด ์—†๊ธฐ ๋•Œ๋ฌธ์— ์ œ์™ธ์‹œ์ผœ์ค๋‹ˆ๋‹ค. vis ๋ฐฐ์—ด์„ ์„ ์–ธํ•ด์ฃผ๊ณ  ์ด๋ฅผ ๋ชจ๋‘ ์ตœ๋Œ€๊ฐ’์œผ๋กœ ์ดˆ๊ธฐํ™” ํ•ด์ค€ ๋‹ค์Œ, vis[next] ์ „์ฒด ์ฝ”๋“œimport java.io.BufferedReader;import java.io.InputStreamReader;import java.util.*;class Main { public stat.. 2024. 11. 20.
[MySQL] SQL ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค 4๋‹จ๊ณ„ ๋‹ค ํ’€์–ด๋ณด๊ธฐ (2) 6๋ฌธ์ œ์ž๋™์ฐจ ๋Œ€์—ฌ ๊ธฐ๋ก ๋ณ„ ๋Œ€์—ฌ ๊ธˆ์•ก ๊ตฌํ•˜๊ธฐ ํฌ์ธํŠธ: ์„œ๋ธŒ ์ฟผ๋ฆฌ, WITH ์ ˆ, ๋Œ€์—ฌ ๊ธฐ๊ฐ„์€ DATEDIFF + 1์ด๋ผ๋Š”๊ฑฐ, CASE WHEN THEN END ๋ฌธ ๋„ˆ๋ฌด ์–ด๋ ต๋‹ค.. https://school.programmers.co.kr/learn/courses/30/lessons/151141 ํ”„๋กœ๊ทธ๋ž˜๋จธ์ŠคSW๊ฐœ๋ฐœ์ž๋ฅผ ์œ„ํ•œ ํ‰๊ฐ€, ๊ต์œก, ์ฑ„์šฉ๊นŒ์ง€ Total Solution์„ ์ œ๊ณตํ•˜๋Š” ๊ฐœ๋ฐœ์ž ์„ฑ์žฅ์„ ์œ„ํ•œ ๋ฒ ์ด์Šค์บ ํ”„programmers.co.kr WITH DISCOUNT AS (SELECT H.HISTORY_ID AS HISTORY_ID, C.DAILY_FEE AS DAILY_FEE,DATEDIFF(H.END_DATE, H.START_DATE) + 1 AS DATEDIFF, C.CAR_TYPE AS CAR_T.. 2024. 11. 10.
[MySQL] ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์ค€๋น„๋ฅผ ์œ„ํ•œ MySQL ๋‚ด์žฅํ•จ์ˆ˜ ์ •๋ฆฌ ๋ฌธ์ž์—ด ๊ด€๋ จ ๋‚ด์žฅ ํ•จ์ˆ˜LOCATE("A", "ABC"): "ABC"์—์„œ "A"๊ฐ€ ๋ช‡๋ฒˆ์งธ์ธ์ง€๋ฅผ ๋ฐ˜ํ™˜SUBSTRING("abc", 2): 2๋ฒˆ์งธ ๋ฌธ์ž๋ถ€ํ„ฐ ๋ฐ˜ํ™˜RIGHT("ABCD", 1): "ABCD" ์˜ค๋ฅธ์ชฝ์—์„œ 1๋ฒˆ์งธ๊นŒ์ง€LEFT("ABCD, 1): "ABCD" ์™ผ์ชฝ์—์„œ 1๋ฒˆ์งธ๊นŒ์ง€UPPER(str), LOWER(str): ๋Œ€๋ฌธ์ž๋กœ ๋ณ€ํ™˜, ์†Œ๋ฌธ์ž๋กœ ๋ณ€ํ™˜CONCAT("ABC", "DEF", "GHI"): ๋ฌธ์ž์—ด ์ด์–ด๋ถ™์ด๊ธฐREPLACE("ABC", "A", "Z"): "ABC"์˜ "A"๋ฅผ "Z"๋กœ ๋ณ€ํ™˜LPAD("DEF", 5, "_"): "DEF" ์™ผ์ชฝ์— "_"๋ฅผ ์ „์ฒด ๋ฌธ์ž์—ด์ด 5๊ธ€์ž๊ฐ€ ๋˜๋„๋ก ๋ถ™์ด๊ธฐ  ์ˆซ์žํ˜•ABS(์ˆซ์ž): ์ ˆ๋Œ€๊ฐ’ ๋ฐ˜ํ™˜CEILING(์‹ค์ˆ˜): ์˜ฌ๋ฆผFLOOR(์‹ค์ˆ˜): ๋‚ด๋ฆผROUND(์‹ค์ˆ˜): ๋ฐ˜์˜ฌ๋ฆผTR.. 2024. 11. 9.
[PS / ๋ฐฑ์ค€] 12904. A์™€ B https://www.acmicpc.net/problem/12904  ํ’€์ดS๊ฐ€ T๊ฐ€ ๋  ์ˆ˜ ์žˆ๋Š”์ง€๋ฅผ ๋”ฐ์ง€์ง€ ์•Š๊ณ  T๊ฐ€ S๊ฐ€ ๋  ์ˆ˜ ์žˆ๋Š”์ง€๋ฅผ ๋”ฐ์ง€๋ฉด ๋˜๋Š” ๋ฌธ์ œ์˜€๋‹ค.T๊ฐ€ S๊ฐ€ ๋  ์ˆ˜ ์žˆ๋Š”์ง€๋ฅผ ๋”ฐ์ง€๋ฉด ๊ฒฝ์šฐ๊ฐ€ ๋”ฑ ๋‘๊ฐ€์ง€๋กœ ๋‚˜๋‰œ๋‹ค. (i) T๊ฐ€ A๋กœ ๋๋‚จ => T์˜ ๋งจ ๋’ค์— ์žˆ๋Š” A๋ฅผ ๋–ผ๋ฉด๋œ๋‹ค.(ii) T๊ฐ€ B๋กœ ๋๋‚จ => T์˜ ๋งจ ๋’ค์— ์žˆ๋Š” B๋ฅผ ๋–ผ๊ณ  ๋ฌธ์ž์—ด์„ ๋’ค์ง‘๋Š”๋‹ค. ์œ„ ๋‘ ๊ฒฝ์šฐ์˜ ์—ฐ์‚ฐ์„ T์™€ S์˜ ๊ธธ์ด๊ฐ€ ๋™์ผํ•ด์งˆ ๋•Œ๊นŒ์ง€ ๋ฐ˜๋ณตํ•ด์ฃผ๋ฉด ๋œ๋‹ค. ์˜ค๋žœ๋งŒ์— StringBuilder๋ฅผ ์จ๋ณด๋‹ˆ๊นŒ ๋ฉ”์†Œ๋“œ๋“ค์ด ์ž˜ ๊ธฐ์–ต๋‚˜์ง€๊ฐ€ ์•Š์•˜๋‹ค.delete(์‹œ์ž‘์ธ๋ฑ์Šค, ๋์ธ๋ฑ์Šค), reverse(), charAt() ์ •๋„๋Š” ๊ผญ ๊ธฐ์–ตํ•ด๋‘์ž์ „์ฒด ์ฝ”๋“œimport java.io.BufferedReader;import java.io.InputSt.. 2024. 11. 8.
[SQL / ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] JOIN ๋ฌธ์ œ ๋ชจ์Œ https://school.programmers.co.kr/learn/courses/30/lessons/131117 ํ”„๋กœ๊ทธ๋ž˜๋จธ์ŠคSW๊ฐœ๋ฐœ์ž๋ฅผ ์œ„ํ•œ ํ‰๊ฐ€, ๊ต์œก, ์ฑ„์šฉ๊นŒ์ง€ Total Solution์„ ์ œ๊ณตํ•˜๋Š” ๊ฐœ๋ฐœ์ž ์„ฑ์žฅ์„ ์œ„ํ•œ ๋ฒ ์ด์Šค์บ ํ”„programmers.co.kr ์šฐ์„  5์›”์— ๋งŒ๋“ค์–ด์ง„ ์ƒํ’ˆ๋“ค์˜ ์ด ์ฃผ๋ฌธ ๊ฐœ์ˆ˜๋ฅผ ๊ตฌํ•ด์•ผํ•œ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ์Šต๋‹ˆ๋‹ค.ํ•ด๋‹น ์ฟผ๋ฆฌ๋Š” ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.SELECT PRODUCT_ID, SUM(AMOUNT)FROM FOOD_ORDERWHERE PRODUCE_DATE >= '2022-05-01' AND PRODUCE_DATE  ๊ทธ๋ฆฌ๊ณ  ์ € AMOUNT์˜ ํ•ฉ๊ณผ ๊ฐ€๊ฒฉ์„ ๊ณฑํ•ด์ฃผ๋ฉด ๋œ๋‹ค๊ณ  ์ƒ๊ฐํ•ด์„œ JOIN์„ ํ™œ์šฉํ•ด์„œ ์ •๋‹ต์ฟผ๋ฆฌ๋ฅผ ์ผ์Šต๋‹ˆ๋‹ค. SELECT FP.PRODUCT_ID AS PRODUCT_ID, F.. 2024. 11. 7.