[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ์„œ์šธ์— ์œ„์น˜ํ•œ ์‹๋‹น ๋ชฉ๋ก ์ถœ๋ ฅํ•˜๊ธฐ | ์˜ค๋ผํด
ยท
๐Ÿ“ Coding Test/SQL
๋ฌธ์ œ์ž๋™์ฐจ ๋Œ€์—ฌ ๊ธฐ๋ก ๋ณ„ ๋Œ€์—ฌ ๊ธˆ์•ก ๊ตฌํ•˜๊ธฐํ’€์ดSELECT A.REST_ID, A.REST_NAME, A.FOOD_TYPE, A.FAVORITES, A.ADDRESS, B.REVIEW_SCOREFROM REST_INFO A JOIN (SELECT REST_ID, ROUND(AVG(REVIEW_SCORE), 2) REVIEW_SCORE FROM REST_REVIEW GROUP BY REST_ID) BON A.REST_ID = B.REST_IDWHERE A.ADDRESS LIKE '์„œ์šธ%'ORDER BY REVIEW_SCORE DESC, FAVORITES DESC;REST_ID์™€ ๋ฆฌ๋ทฐ์ ์ˆ˜ ํ‰๊ท  ๋‘ ๊ฐœ์˜ ์ปฌ๋Ÿผ์„ ๊ฐ–๋Š” ์ธ๋ผ์ธ ๋ทฐ๋ฅผ ๋งŒ๋“ค์–ด ์กฐ์ธํ•˜์—ฌ ํ’€์ดํ•˜์˜€์Šต๋‹ˆ๋‹ค.
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค Lv0] ์ˆจ์–ด์žˆ๋Š” ์ˆซ์ž์˜ ๋ง์…ˆ (2) | ์ž๋ฐ”
ยท
๐Ÿ“ Coding Test/Programmers Lv0
๋ฌธ์ œ์ˆจ์–ด์žˆ๋Š” ์ˆซ์ž์˜ ๋ง์…ˆ (2)ํ’€์ดclass Solution { public int solution(String my_string) { int answer = 0; String[] strArr = my_string.replaceAll("[a-zA-Z]", " ").split(" "); for(String str : strArr) { if(!str.equals("")) answer += Integer.parseInt(str); } return answer; }}๋ชจ๋“  ์•ŒํŒŒ๋ฒณ์„ ์ œ๊ฑฐํ•ด์•ผํ•˜๋Š”๋ฐ replaceAll("[a-zA-Z]", " ")๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ชจ๋“  ์•ŒํŒŒ๋ฒณ์„ ์ œ๊ฑฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ์ฆ๊ฒจ์ฐพ๊ธฐ๊ฐ€ ๊ฐ€์žฅ ๋งŽ์€ ์‹๋‹น ์ •๋ณด ์ถœ๋ ฅํ•˜๊ธฐ | ์˜ค๋ผํด
ยท
๐Ÿ“ Coding Test/SQL
๋ฌธ์ œ์ฆ๊ฒจ์ฐพ๊ธฐ๊ฐ€ ๊ฐ€์žฅ ๋งŽ์€ ์‹๋‹น ์ •๋ณด ์ถœ๋ ฅํ•˜๊ธฐํ’€์ดSELECT FOOD_TYPE, REST_ID, REST_NAME, FAVORITESFROM REST_INFOWHERE (FOOD_TYPE, FAVORITES) IN ( SELECT FOOD_TYPE, MAX(FAVORITES) FROM REST_INFO GROUP BY FOOD_TYPE)ORDER BY FOOD_TYPE DESC;GROUP BY๋ฅผ ์ด์šฉํ•ด์„œ ์Œ์‹๋ณ„ ์ตœ๋Œ€ ์ฆ๊ฒจ์ฐพ๊ธฐ ์ˆ˜๋ฅผ ๋ฝ‘์€ ์„œ๋ธŒ์ฟผ๋ฆฌ๋ฅผ ์ด์šฉํ•ด์„œ ํ’€์ดํ•ฉ๋‹ˆ๋‹ค.
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค Lv3] ๊ฐ€์žฅ ๋จผ ๋…ธ๋“œ | ์ž๋ฐ”
ยท
๐Ÿ“ Coding Test/Programmers Lv3
๋ฌธ์ œ๊ฐ€์žฅ ๋จผ ๋…ธ๋“œํ’€์ดimport java.util.*;class Solution { public int solution(int n, int[][] edge) { int answer = 0; int[] visited = new int[n + 1]; ArrayList> graph = new ArrayList(); for(int i = 0; i ()); } for(int i = 0; i > graph, int[] visited, int start) { Queue q = new LinkedList(); q.offer(start); visited[start] = 1; ..
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ์ฃผ๋ฌธ๋Ÿ‰์ด ๋งŽ์€ ์•„์ด์Šคํฌ๋ฆผ๋“ค ์กฐํšŒํ•˜๊ธฐ | ์˜ค๋ผํด
ยท
๐Ÿ“ Coding Test/SQL
๋ฌธ์ œ์ฃผ๋ฌธ๋Ÿ‰์ด ๋งŽ์€ ์•„์ด์Šคํฌ๋ฆผ๋“ค ์กฐํšŒํ•˜๊ธฐํ’€์ดSELECT FLAVORFROM ( SELECT FLAVOR, SUM(TOTAL_ORDER) SUM FROM ( SELECT * FROM FIRST_HALF UNION ALL SELECT * FROM JULY ) GROUP BY FLAVOR ORDER BY SUM DESC) WHERE ROWNUM ์ƒ๋ฐ˜๊ธฐ์™€ 7์›”์— ๊ฐ€์žฅ ๋งŽ์ด ํŒ”๋ฆฐ FLAVOR๋ฅผ ์ˆœ์„œ๋Œ€๋กœ 3๊ฐœ ๊ตฌํ•˜๋Š” ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค. ์ƒ๋ฐ˜๊ธฐ ํŒ๋งค์ •๋ณด์™€ 7์›” ํŒ๋งค์ •๋ณด ์ค‘ ๊ฒน์น˜๋Š” ๋ฐ์ดํ„ฐ๊ฐ€ ์—†๊ธฐ ๋•Œ๋ฌธ์—, UNION ALL์„ ์‚ฌ์šฉํ•ด์„œ ํ’€์ดํ–ˆ์Šต๋‹ˆ๋‹ค. *์ฐธ๊ณ  : UNION์€ ์ค‘๋ณต๋œ row๋ฅผ ์ œ์™ธํ•˜๊ณ (DISTINCT), UNION ALL์€ ์ค‘๋ณต๋œ row๋„ ..
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ์ทจ์†Œ๋˜์ง€ ์•Š์€ ์ง„๋ฃŒ ์˜ˆ์•ฝ ์กฐํšŒํ•˜๊ธฐ | ์˜ค๋ผํด
ยท
๐Ÿ“ Coding Test/SQL
๋ฌธ์ œ์ทจ์†Œ๋˜์ง€ ์•Š์€ ์ง„๋ฃŒ ์˜ˆ์•ฝ ์กฐํšŒํ•˜๊ธฐํ’€์ดSELECT A.APNT_NO, P.PT_NAME, P.PT_NO, A.MCDP_CD, D.DR_NAME, A.APNT_YMDFROM APPOINTMENT A JOIN PATIENT P ON A.PT_NO = P.PT_NO JOIN DOCTOR D ON A.MCDP_CD = D.MCDP_CD AND A.MDDR_ID = D.DR_IDWHERE TO_CHAR(A.APNT_YMD, 'YYYYMMDD') = '20220413' AND A.MCDP_CD = 'CS' AND A.APNT_CNCL_YN = 'N'ORDER BY A.APNT_YMD;
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ์ž๋™์ฐจ ๋Œ€์—ฌ ๊ธฐ๋ก ๋ณ„ ๋Œ€์—ฌ ๊ธˆ์•ก ๊ตฌํ•˜๊ธฐ | ์˜ค๋ผํด
ยท
๐Ÿ“ Coding Test/SQL
๋ฌธ์ œ์ž๋™์ฐจ ๋Œ€์—ฌ ๊ธฐ๋ก ๋ณ„ ๋Œ€์—ฌ ๊ธˆ์•ก ๊ตฌํ•˜๊ธฐํ’€์ดSELECT AA.HISTORY_ID, (AA.RENT_DATE * AA.DAILY_FEE) * (100 - NVL(DISCOUNT_RATE, 0)) / 100 FEEFROM (SELECT HISTORY_ID, H.END_DATE - H.START_DATE + 1 RENT_DATE, CASE WHEN H.END_DATE - H.START_DATE + 1 >= 90 THEN '90์ผ ์ด์ƒ' WHEN H.END_DATE - H.START_DATE + 1 >= 30 THEN '30์ผ ์ด์ƒ' WHEN H.END_DATE - H.START_DATE + 1 >= ..
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค Lv2] ์˜ฌ๋ฐ”๋ฅธ ๊ด„ํ˜ธ | ์ž๋ฐ”
ยท
๐Ÿ“ Coding Test/Programmers Lv2
๋ฌธ์ œ์˜ฌ๋ฐ”๋ฅธ ๊ด„ํ˜ธํ’€์ด 1import java.util.*;class Solution { boolean solution(String s) { String[] strArr = s.split(""); Stack stack = new Stack(); for(int i = 0; i ์ •ํ™•์„ฑ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋Š” ํ†ต๊ณผํ–ˆ์ง€๋งŒ, ํšจ์œจ์„ฑ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋ฅผ ํ†ต๊ณผํ•˜๋Š”๋ฐ ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค.์ด ๋ฌธ์ œ์˜ ์กฐ๊ฑด ์ค‘ ํ•˜๋‚˜๋Š” ๋ฌธ์ž์—ด์ด ์ตœ๋Œ€ 100,000์ด ๋ ์ˆ˜ ์žˆ๋‹ค๋Š” ์ ์ด๊ณ , split์„ ์‚ฌ์šฉํ•˜๋ฉด ๋ฌธ์ž์—ด ์ „์ฒด๋ฅผ ์ƒˆ๋กœ์šด ๋ฐฐ์—ด๋กœ ๋ณต์‚ฌํ•ด์•ผ ํ•˜๋ฉฐ, ์ถ”๊ฐ€์ ์ธ ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ๊ณผ ์ฒ˜๋ฆฌ ์‹œ๊ฐ„์ด ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.ํ’€์ด 2class Solution { boolean solution(String s) { String[] ..
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ์กฐ๊ฑด์— ๋งž๋Š” ์‚ฌ์šฉ์ž ์ •๋ณด ์กฐํšŒํ•˜๊ธฐ | ์˜ค๋ผํด
ยท
๐Ÿ“ Coding Test/SQL
[level 3] ์กฐ๊ฑด์— ๋งž๋Š” ์‚ฌ์šฉ์ž ์ •๋ณด ์กฐํšŒํ•˜๊ธฐ - 164670๋ฌธ์ œ ๋งํฌ์„ฑ๋Šฅ ์š”์•ฝ๋ฉ”๋ชจ๋ฆฌ: 0.0 MB, ์‹œ๊ฐ„: 0.00 ms๊ตฌ๋ถ„์ฝ”๋”ฉํ…Œ์ŠคํŠธโ€…์—ฐ์Šต > String๏ผŒโ€…Dateํ’€์ดSELECT USER_ID, NICKNAME, CITY || ' ' || STREET_ADDRESS1 || ' ' || STREET_ADDRESS2 ์ „์ฒด์ฃผ์†Œ, SUBSTR(TLNO, 1, 3) || '-' || SUBSTR(TLNO, 4, 4) || '-' || SUBSTR(TLNO, 8, 4) ์ „ํ™”๋ฒˆํ˜ธFROM USED_GOODS_USERWHERE USER_ID IN ( SELECT WRITER_ID FROM USED_GOODS_BOARD GROUP BY WRITER_ID HAVING COUNT..