๐Ÿ‘จ๐Ÿป‍๐Ÿ’ป PS/JAVA

    [JAVA] 2022 KAKAO BLIND RECRUITMENTใ€k์ง„์ˆ˜์—์„œ ์†Œ์ˆ˜ ๊ฐœ์ˆ˜ ๊ตฌํ•˜๊ธฐใ€‘

    ๋งค์šฐ ๊ฐ„๋‹จํ–ˆ๋˜ ๋ฌธ์ œ์˜€๋‹ค. k์ง„์ˆ˜๋กœ ๋ณ€ํ™˜ํ•˜๋Š” transform ํ•จ์ˆ˜๋ฅผ ์ •์˜ํ•˜๊ณ  ๋ฐ˜ํ™˜๋ฐ›์€ ๊ฐ’์„ ์ •๊ทœ์‹์œผ๋กœ ์ˆซ์ž๋ฅผ ์ถ”์ถœํ–ˆ๋‹ค. ์—๋ผํ† ์Šค ํ…Œ๋„ค์Šค ์ฒด๋กœ ์†Œ์ˆ˜๋ฅผ ํŒ๋ณ„ํ•˜๋Š” ๋ฉ”์„œ๋“œ๋„ ์ •์˜ํ•ด์„œ ์†Œ์ˆ˜๋ฅผ ํŒ๋ณ„ํ–ˆ๊ณ , ์ฃผ์˜ํ•  ์ ์€ ๋ฌธ์ž์—ด ์ˆซ์ž๊ฐ€ int ๋ฒ”์œ„๋ฅผ ์ดˆ๊ณผํ•˜์—ฌ ์ด์ƒํ•œ ๋‹ต์„ ๋„์ถœํ•  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ long ํƒ€์ž…์œผ๋กœ ๋ฐ›์•„์„œ ํ™•์ธํ•ด์•ผํ•œ๋‹ค. import java.util.*; import java.util.regex.*; class Solution { public int solution(int n, int k) { int answer = 0; String num = transform(n,k); Pattern pattern = Pattern.compile("[1-9]+"); Matcher matcher = pattern.matcher..

    [JAVA] 2018 KAKAO BLIND RECRUITMENT ใ€๋‰ด์Šค ํด๋Ÿฌ์Šคํ„ฐ๋งใ€‘

    ์ฃผ์–ด์ง„ ๋ฌธ์ž์—ด์„ ๋ฌธ์ž๋กœ๋งŒ ์ด๋ฃจ์–ด์ง€๋Š” ์กฐํ•ฉ์„ ๋งŒ๋“ค์–ด์„œ Map์— ๊ฐœ์ˆ˜์™€ ๊ธฐ๋กํ•œ๋‹ค. (์˜ˆ์‹œ,["fr":2,"re":1,....]) ๋‘ ๋ฌธ์ž์—ด์„ ์กฐํ•ฉ๋ณ„ ๊ฐฏ์ˆ˜๋ฅผ ๊ธฐ๋กํ•œ Map์„ ์ด์šฉํ•ด์„œ ๊ต์ง‘ํ•ฉ ์ˆ˜๋ฅผ ๊ตฌํ•œ๋‹ค. ๊ต์ง‘ํ•ฉ์ˆ˜๋Š” ์ค‘๋ณต๋„ ํ—ˆ์šฉํ•˜๋ฏ€๋กœ, ๊ฐ Map์— ๊ธฐ๋ก๋˜์–ด์žˆ๋Š” ์ˆ˜์˜ ์ตœ์†Ÿ๊ฐ’์œผ๋กœ ๊ธฐ๋กํ•œ๋‹ค. ๊ทธ๋ฆฌ๊ณ  (ํ•ฉ์ง‘ํ•ฉ ์ˆ˜ - ๊ต์ง‘ํ•ฉ์ˆ˜)๊ฐ€ ๋ถ„๋ชจ, ๊ต์ง‘ํ•ฉ ์ˆ˜๊ฐ€ ๋ถ„์ž๊ฐ€ ๋˜์–ด ๋‹ต์„ ๊ตฌํ•œ๋‹ค. import java.util.*; class Solution { HashMap mapA; HashMap mapB; public int solution(String str1, String str2) { int answer = 0; mapA = new HashMap(); mapB = new HashMap(); getCombination(mapA,st..

    [JAVA] 2022 KAKAO TECH INTERNSHIP ใ€๋‘ ํ ํ•ฉ ๊ฐ™๊ฒŒ ๋งŒ๋“ค๊ธฐใ€‘

    ๋ฌธ์ œ ์ž์ฒด๋Š” ๊ฐ„๋‹จํ•˜๋‹ค. ์™ผ์ชฝ ํ ์ดํ•ฉ์ด ์ปค์ง€๋ฉด, ์™ผ์ชฝ ํ ์›์†Œ๋ฅผ ๋นผ์„œ ์˜ค๋ฅธ์ชฝ ํ๋กœ ์˜ฎ๊ธฐ๊ณ  ์˜ค๋ฅธ์ชฝ ํ ์ดํ•ฉ์ด ์ปค์ง€๋ฉด ์˜ค๋ฅธ์ชฝ ํ ์›์†Œ๋ฅผ ๋นผ์„œ ์™ผ์ชฝ ํ๋กœ ์˜ฎ๊ธฐ๋ฉด ๋œ๋‹ค. ๊ทธ๋ฆฌ๊ณ [1,4] [4,8] ๊ณผ ๊ฐ™์ด ์ฃผ์–ด์ง€๋ฉด ๋ฌดํ•œ ๋ฃจํ”„๊ฐ€ ๋Œ ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์—, while๋ฌธ ํƒˆ์ถœ ์กฐ๊ฑด์„ (๋‘ ํ์˜ ๊ธธ์ด ํ•ฉ*2) ์ด์ƒ ๋ฐ˜๋ณต๋˜๋ฉด ํƒˆ์ถœํ•˜๋„๋ก ์„ค์ •ํ•ด๋†จ๋‹ค. ์ตœ์•…์˜ ๊ฒฝ์šฐ๋ฅผ ๊ฐ€์ •ํ•ด์„œ ์ƒ๊ฐํ•ด๋ดค๋‹ค. ํ1 [1 2 3....n] // ํ 2 [1 2 3 ....m] ํ1 [n] // ํ 2[1 2 3 ...m 1 2 3....n-1] (์•ฝ n-1๋ฒˆ ์†Œ์š”) ํ1[1 2 3 ....m] // ํ2[1 2 3 ....n] (์•ฝ m+1๋ฒˆ ์†Œ์š”) ํ 1๊ณผ ํ2์˜ ์›์†Œ๊ฐ€ ์™„์ „ํžˆ ๋ฐ”๋€Œ๋ ค๋ฉด n+m๋ฒˆ์ด ์†Œ์š”๋˜๊ณ  ๋‹ค์‹œ ํ1์ด ์ฒ˜์Œ ํ1์›์†Œ๋กœ ๋Œ์•„๊ฐ€๋ ค๋ฉด n+m๋ฒˆ..

    [JAVA] 2020 ์นด์นด์˜ค ์ธํ„ด์‹ญ ใ€๋ณด์„ ์‡ผํ•‘ใ€‘

    Map์„ ์ด์šฉํ•ด์„œ ๋ณด์„ ์ข…๋ฅ˜๋ณ„ ๊ฐฏ์ˆ˜๋ฅผ ๊ธฐ๋กํ•œ๋‹ค. ๊ทธ๋ฆฌ๊ณ  L์„ 0์œผ๋กœ ์žก๊ณ , gems[L] ์ด Map์— ์กด์žฌํ•˜๋ฉด์„œ, ๊ฐ’์ด 2์ด์ƒ์œผ๋กœ ์กด์žฌํ•˜๋Š” ๊ฒฝ์šฐ ๊ฐ’์ด 1์ด ๋ ๋•Œ๊นŒ์ง€ L์„ ์ฆ๊ฐ€์‹œํ‚จ๋‹ค. ๊ทธ๋Ÿฌ๋ฉด, ์ œ์ผ ์•ž์ชฝ์— ์ค‘๋ณต์œผ๋กœ ์กด์žฌํ•˜๋Š” ๋ณด์„์„ ์ œ์™ธ์‹œํ‚ฌ ์ˆ˜ ์žˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ , Map์˜ size ์ฆ‰, ๊ธฐ๋ก๋œ ๋ณด์„์˜ ๊ฐฏ์ˆ˜๊ฐ€ ๋ณด์„ ์ข…๋ฅ˜ ์ˆ˜์™€ ์ผ์น˜ํ•˜๋ฉด ๋ชจ๋“  ๋ณด์„์ด ์กด์žฌํ•˜๋Š” ๊ตฌ๊ฐ„์ž„์„ ์˜๋ฏธํ•˜๋ฏ€๋กœ ์ •๋‹ต์„ ๊ฐฑ์‹ ํ•˜๊ณ , ์ด๋ฏธ ๊ธฐ๋ก๋œ ๊ธธ์ด๋ณด๋‹ค ์ž‘์€ ๊ฒฝ์šฐ์—๋งŒ ๊ฐฑ์‹ ํ•œ๋‹ค. import java.util.*; class Solution { public int[] solution(String[] gems) { int[] answer = new int[2]; int cnt = new HashSet(Arrays.asList(gems)).size(); in..

    [JAVA] 2021 KAKAO BLIND RECRUITMENT ใ€๋ฉ”๋‰ด ๋ฆฌ๋‰ด์–ผใ€‘

    ๋ฐฑํŠธ๋ž˜ํ‚น์œผ๋กœ ์Œ์‹ ์กฐํ•ฉ์„ ๊ตฌํ•œ ๋’ค, ์Œ์‹ ์กฐํ•ฉ ๋ณ„ ์ฃผ๋ฌธ ํšŸ์ˆ˜๋ฅผ ๊ตฌํ•œ๋‹ค. (bt() ๋ฉ”์„œ๋“œ ์‚ฌ์šฉ) ์™€ ๊ฐ™์ด ์ž…๋ ฅ๋  ๊ฒƒ์ด๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์ด ๋งต์„ ์ด์šฉํ•ด์„œ, ๋ฅผ ๊ตฌํ•œ๋‹ค. (getMaxMenu()) ๊ทธ๋ฆฌ๊ณ  ์ฝ”์Šค์‚ฌ์ด์ฆˆ๋ณ„ ์ตœ๋Œ€ ์ฃผ๋ฌธํšŸ์ˆ˜๋ฅผ ์•Œ๊ฒŒ ๋์œผ๋ฏ€๋กœ, ์ฝ”์Šค ์‚ฌ์ด์ฆˆ์™€ ์Œ์‹ ์กฐํ•ฉ์˜ ๊ธธ์ด๊ฐ€ ์ผ์น˜ํ•˜๋ฉด์„œ [์ฃผ๋ฌธํšŸ์ˆ˜์™€ ์ตœ๋Œ€ ์ฃผ๋ฌธํšŸ์ˆ˜๊ฐ€ ์ผ์น˜ํ•œ ๊ฒƒ & 2๋ฒˆ ์ด์ƒ ์ฃผ๋ฌธ ๋œ]๊ฒƒ์˜ Max ๊ฐ’์„ ๋ฆฌ์ŠคํŠธ ์ž๋ฃŒ๊ตฌ์กฐ์ธ ans์— ๊ธฐ๋กํ•œ๋‹ค. ์ •๋ ฌํ•œ ๋’ค, ๋ฐฐ์—ด๋กœ ๋ณ€ํ™˜ํ•ด์„œ ๋ฐ˜ํ™˜ํ•œ๋‹ค import java.util.*; class Solution { HashMap map; HashMap max; List ans; StringBuilder sb; public String[] solution(String[] orders, int[] course) { map..

    [JAVA] 2019 ์นด์นด์˜ค ๊ฐœ๋ฐœ์ž ๊ฒจ์šธ ์ธํ„ด์‹ญ ใ€ํŠœํ”Œใ€‘

    ๋งต๊ณผ ๋ฆฌ์ŠคํŠธ๋ฅผ ํ™œ์šฉํ•ด์„œ ํ’€์—ˆ๋‹ค. ๋จผ์ € ์‰ฝ๊ฒŒ ์ƒ๊ฐํ•  ์ˆ˜ ์žˆ๋Š” ์•„์ด๋””์–ด๊ฐ€, ํŠน์ • ์ˆซ์ž๊ฐ€ ๋“ฑ์žฅํ•˜๋Š” ํšŸ์ˆ˜๋ฅผ ๊ตฌํ•˜๊ณ  ๋“ฑ์žฅ์„ ๋งŽ์ด ํ•˜๋Š” ์ˆœ์„œ๋กœ ๋‚˜์—ดํ•˜๋ฉด ๋‹ต์ด ๋  ๊ฒƒ์ด๋‹ค. "{{2},{2,1},{2,1,3},{2,1,3,4}}" ์œ„ ์˜ˆ์ œ๋ฅผ ์˜ˆ์‹œ๋กœ ์„ค๋ช…ํ•ด๋ณด๊ฒ ๋‹ค. int [] result = Arrays.stream(s.replace("{","").replace("}","").split(",")) .mapToInt(Integer::valueOf) .toArray(); ์œ„ ๋กœ์ง์„ ํ†ตํ•ด [2, 2, 1, 2, 1, 3, 2, 1, 3, 4] ์™€ ๊ฐ™์€ int ๋ฐฐ์—ด๋กœ ์ถ”์ถœํ•  ์ˆ˜ ์žˆ๋‹ค. ์ด ๋ฐฐ์—ด์„ Map์„ ์ด์šฉํ•ด์„œ ์นด์šดํŒ…์„ ํ•œ๋‹ค. HashMap map = new HashMap(); for(int num : result){ map..

    [JAVA] 2018 KAKAO BLIND RECRUITMENT ใ€์บ์‹œใ€‘

    ํ๋กœ ๊ฐ„๋‹จํ•˜๊ฒŒ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์—ˆ๋˜ ๋ฌธ์ œ, ํ๋ฅผ ์บ์‹œ ์ €์žฅ๊ณต๊ฐ„์ฒ˜๋Ÿผ ์‚ฌ์šฉํ•œ๋‹ค. ํ๊ฐ€ ์ •ํ•ด์ง„ ์บ์‹œ ์‚ฌ์ด์ฆˆ์— ๋„๋‹ฌํ•˜๋ฉด, poll() ํ•ด์ค€๋’ค offer() ํ•ด์ค€๋‹ค. ๋งŒ์•ฝ, ์บ์‹œ ํžˆํŠธ๊ฐ€ ๋˜๋ฉด, ์ตœ์‹  ์บ์‹œ๋กœ ์—…๋ฐ์ดํŠธ ํ•ด์ค˜์•ผ ํ•˜๋ฏ€๋กœ remove()ํ•ด์ค€ ๋’ค offer() ํ•ด์ค€๋‹ค. ์บ์‹œ์‚ฌ์ด์ฆˆ๊ฐ€ 0์ธ ๊ฒฝ์šฐ์— ["LA","la"] ์ž…๋ ฅ์ด ์ฃผ์–ด์ง€๋ฉด ๋‹ต์ด 10์ด ๋‚˜์™€์•ผ ํ•˜๋ฏ€๋กœ, cache ์‚ฌ์ด์ฆˆ๊ฐ€ 0์ธ ๊ฒฝ์šฐ๋งŒ ๋”ฐ๋กœ ์ฒ˜๋ฆฌ๋ฅผ ํ•ด์ฃผ๋ฉด ๋œ๋‹ค. import java.util.*; class Solution { Queue cache; public int solution(int cacheSize, String[] cities) { int answer = 0; cache = new LinkedList(); if(cacheSize==0){ ret..

    [ํŒŒ์ด์ฌ PYTHON] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ใ€์‚ผ๊ฐ ๋‹ฌํŒฝ์ดใ€‘

    def solution(n): result = [] checked = [] # ์ตœ์ข… ๋„˜๋ฒ„ final = (n) * (n + 1) // 2 # ๊ทธ๋ž˜ํ”„์™€ ๋ฐฉ๋ฌธ ์—ฌ๋ถ€ checked ์ดˆ๊ธฐํ™” for i in range(1, n + 1): arr = [j + 1 for j in range(i)] chk = [False for j in range(i)] result.append(arr) checked.append(chk) # ์›€์ง์ผ ์ˆ˜ ์žˆ๋Š” ๋ฐฉํ–ฅ ์™ผ์ชฝ ์•„๋ž˜ ๋ฐฉํ–ฅ ๋ถ€ํ„ฐ ์ง„ํ–‰ dr = [1, 0, -1] dc = [0, 1, -1] direct = 0 # 0,0 1๋ฒˆ ๋ถ€ํ„ฐ ๋„˜๋ฒ„๋ง ์‹œ์ž‘ num = 1 r, c = 0, 0 while True: # ๋„˜๋ฒ„๋ง์ด ์ตœ์ข…๋„˜๋ฒ„์™€ ๋™์ผํ•ด์ง€๋ฉด ๋ฃจํ”„ ์ข…๋ฃŒ if num == final: re..

    [ํŒŒ์ด์ฌ PYTHON] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ใ€๋’ค์— ์žˆ๋Š” ํฐ ์ˆ˜ ์ฐพ๊ธฐใ€‘

    ์ง„์งœ ๋„ˆ๋ฌด ์–ด๋ ค์› ๋‹ค.. ๋ฌธ์ œ๋ฅผ ๊ฒจ์šฐ ์ดํ•ดํ•ด๋ดค๊ณ  ๋‚ด๊ฐ€ ์ดํ•ดํ•œ ๋ฐ”ํƒ•์œผ๋กœ ์˜ˆ์ œ๋ฅผ ํ†ตํ•ด ์„ค๋ช…ํ•ด๋ณด๊ฒ ๋‹ค. stack์„ ์‚ฌ์šฉํ•  ๊ฒƒ์ด๊ณ , stack์—๋Š” ๊ฐ’์ด ์•„๋‹Œ ์ธ๋ฑ์Šค๋ฅผ ๊ฐฑ์‹ ํ•ด ๋‚˜๊ฐˆ ๊ฒƒ์ด๋‹ค. ๋จผ์ € ์ฒซ๋ฒˆ์งธ ์›์†Œ(index = 0)์ธ 9๋Š” ๋น„๊ต๋Œ€์ƒ์ด ์—†์œผ๋ฏ€๋กœ stack์— ๊ทธ๋ƒฅ ์ž…๋ ฅํ•œ๋‹ค. stack์— index๊ฐ€ ์•„์ง ์กด์žฌํ•œ๋‹ค๋Š” ๋œป์€ ์•„์ง ๋’ท ํฐ์ˆ˜๋ฅผ ๋งŒ๋‚˜์ง€ ๋ชปํ–ˆ๋‹ค๋Š” ์˜๋ฏธ์ด๋‹ค. ๊ทธ ๋‹ค์Œ ๋‘๋ฒˆ์งธ ์›์†Œ(index = 1)์€ ๊ฐ’์ด 1์ด๊ณ  stack์„ ํ™•์ธํ•ด์„œ ๋’ท ํฐ ์ˆ˜๋กœ์„œ ์—ญํ• ์„ ํ•  ์ˆ˜ ์žˆ๋Š”์ง€ ํ™•์ธํ•ด๋ณธ๋‹ค. ํ•˜์ง€๋งŒ stack์— ์ €์žฅ๋˜์–ด ์žˆ๋Š” ์ธ๋ฑ์Šค๋กœ ๊ฐ’์„ ํ™•์ธํ•ด๋ณด๋‹ˆ 1๋ณด๋‹ค ํฐ 9์ด๋ฏ€๋กœ ์†Œ๊ฑฐํ•  ์ˆ˜ ์—†๋‹ค. stack์— ๋ณ€ํ™” ์—†์ด index 1์„ ์Šคํƒ์— ์ถ”๊ฐ€ํ•œ๋‹ค. ๊ทธ ๋‹ค์Œ 3๋ฒˆ์งธ ์›์†Œ์ธ (index = 2) 5๊ฐ€ ๋’ท ํฐ ์ˆ˜ ์—ญํ• ์„ ํ•  ..

    [ํŒŒ์ด์ฌ PYTHON · ์ž๋ฐ” JAVA] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šคใ€์ด์ง„ ๋ณ€ํ™˜ ๋ฐ˜๋ณตํ•˜๊ธฐใ€‘

    ์ž๋ฐ” ์ฝ”๋“œ class Solution { public int[] solution(String s) { int[] answer = {}; int zero = 0; int tran = 0; while(!s.equals("1")){ int numOfZero = 0; int numOfOne = 0; for(int i=0;i

    [ํŒŒ์ด์ฌ PYTHON · ์ž๋ฐ” JAVA] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šคใ€์˜ฌ๋ฐ”๋ฅธ ๊ด„ํ˜ธใ€‘

    ์ž๋ฐ” ์ฝ”๋“œ import java.util.*; class Solution { boolean solution(String s) { int result =0; for(int i=0;i

    [ํŒŒ์ด์ฌ PYTHON · ์ž๋ฐ” JAVA] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ใ€์ตœ์†Ÿ๊ฐ’ ๋งŒ๋“ค๊ธฐใ€‘

    ์ž๋ฐ” ์ฝ”๋“œ import java.util.*; class Solution { public int solution(int []A, int []B) { int answer = 0; Arrays.sort(A); Arrays.sort(B); for(int i=0;i

    [ํŒŒ์ด์ฌ PYTHON · ์ž๋ฐ” JAVA] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šคใ€์ตœ๋Œ“๊ฐ’๊ณผ ์ตœ์†Ÿ๊ฐ’ใ€‘

    ๋ฌธ์ž์—ด์„ ์ˆซ์ž ๋ฐฐ์—ด๋กœ ๋งŒ๋“ค์–ด ์ค€ ๋’ค, ์ตœ๋Œ“๊ฐ’๊ณผ ์ตœ์†Ÿ๊ฐ’์„ ๊ตฌํ•˜๋ฉด ๋˜๋Š” ๊ฐ„๋‹จํ•œ ๋ฌธ์ œ์ด๋‹ค. ํŒŒ์ด์ฌ์˜ ๊ฒฝ์šฐ max() ์™€ min() ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋˜๊ณ  ์ž๋ฐ”๋Š” Math.max() ์™€ Math.min() ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค. ์ž๋ฐ” ์ฝ”๋“œ import java.util.*; import java.io.*; class Solution { public String solution(String s) { int[] arr = Arrays.stream(s.split(" ")).mapToInt(str->Integer.valueOf(str)).toArray(); int max = arr[0]; int min = arr[0]; for(int num : arr){ max = Math.max(max,num); min = Math...

    [ํŒŒ์ด์ฌ PYTHON · ์ž๋ฐ” JAVA] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šคใ€JadenCase ๋ฌธ์ž์—ด ๋งŒ๋“ค๊ธฐใ€‘

    ๋ฌธ์ œ ํฌ์ธํŠธ : ๋ชจ๋“  ๋ฌธ์ž๋ฅผ ์†Œ๋ฌธ์ž๋กœ ๋ณ€ํ™˜ํ•œ๋‹ค. ํŒŒ์ด์ฌ์˜ ๊ฒฝ์šฐ๋Š” .lower() ์ž๋ฐ”์˜ ๊ฒฝ์šฐ๋Š” toLowerCase() ๋ฅผ ์‚ฌ์šฉ ๊ทธ๋ฆฌ๊ณ  ์ฒซ ๋ฌธ์ž๋งŒ ์•ŒํŒŒ๋ฒณ์ด๋ฉด ๋Œ€๋ฌธ์ž๋กœ ์ง์ ‘ ๋งŒ๋“ค์–ด์ฃผ๊ณ , ๋‚˜๋จธ์ง€๋Š” ๊ณต๋ฐฑ ๋‹ค์Œ์— ์˜ค๋Š” ๋ฌธ์ž๊ฐ€ ์•ŒํŒŒ๋ฒณ์ธ ๊ฒฝ์šฐ์—๋งŒ ๋Œ€๋ฌธ์ž๋กœ ๋ณ€ํ™˜์‹œ์ผœ์ค€๋‹ค. ์ž๋ฐ” ์ฝ”๋“œ import java.util.*; class Solution { public String solution(String s) { String answer = ""; s=s.toLowerCase(); StringBuilder sb = new StringBuilder(); for(int i=0;i

    [JAVA] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์Šคํƒ/ํ -ใ€๋‹ค๋ฆฌ๋ฅผ ์ง€๋‚˜๋Š” ํŠธ๋Ÿญใ€‘

    import java.util.*; class Solution { public int solution(int bridge_length, int weight, int[] truck_weights) { Queue bridge = new LinkedList(); Queue truck = new LinkedList(); for(int i=0;i=totalWeight+waitingTruck)){ bridge.offer(truck.poll()); totalWeight+=waitingTruck; totalTruckNum++; //์ฐจ๊ฐ€ ๋” ๋ชป์˜ฌ๋ผ์˜ค๋Š” ๊ฒฝ์šฐ }else{ bridge.offer(0); } time++; } time+=bridge_length; return time; } } ๊ฒจ์šฐ๊ฒจ์šฐ ํ˜ผ์ž ํž˜์œผ๋กœ ํ’€์—ˆ๋‹ค. ๋จผ..