๋ฐ˜์‘ํ˜•

์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ์—ฐ์Šต 10

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/JS] ํ”ผ์ž ๋‚˜๋ˆ  ๋จน๊ธฐ (2)

Problem Description ๋จธ์“ฑ์ด๋„ค ํ”ผ์ž๊ฐ€๊ฒŒ๋Š” ํ”ผ์ž๋ฅผ ์—ฌ์„ฏ ์กฐ๊ฐ์œผ๋กœ ์ž˜๋ผ ์ค๋‹ˆ๋‹ค. ํ”ผ์ž๋ฅผ ๋‚˜๋ˆ ๋จน์„ ์‚ฌ๋žŒ์˜ ์ˆ˜ n์ด ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์งˆ ๋•Œ, n๋ช…์ด ์ฃผ๋ฌธํ•œ ํ”ผ์ž๋ฅผ ๋‚จ๊ธฐ์ง€ ์•Š๊ณ  ๋ชจ๋‘ ๊ฐ™์€ ์ˆ˜์˜ ํ”ผ์ž ์กฐ๊ฐ์„ ๋จน์–ด์•ผ ํ•œ๋‹ค๋ฉด ์ตœ์†Œ ๋ช‡ ํŒ์„ ์‹œ์ผœ์•ผ ํ•˜๋Š”์ง€๋ฅผ return ํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด๋ณด์„ธ์š”. Restrictions. 1 ≤ n ≤ 100 Input/Output Example ์ž…์ถœ๋ ฅ ์˜ˆ #1 6๋ช…์ด ๋ชจ๋‘ ๊ฐ™์€ ์–‘์„ ๋จน๊ธฐ ์œ„ํ•ด ํ•œ ํŒ์„ ์‹œ์ผœ์•ผ ํ”ผ์ž๊ฐ€ 6์กฐ๊ฐ์œผ๋กœ ๋ชจ๋‘ ํ•œ ์กฐ๊ฐ์”ฉ ๋จน์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ž…์ถœ๋ ฅ ์˜ˆ #2 10๋ช…์ด ๋ชจ๋‘ ๊ฐ™์€ ์–‘์„ ๋จน๊ธฐ ์œ„ํ•ด ์ตœ์†Œ 5ํŒ์„ ์‹œ์ผœ์•ผ ํ”ผ์ž๊ฐ€ 30์กฐ๊ฐ์œผ๋กœ ๋ชจ๋‘ ์„ธ ์กฐ๊ฐ์”ฉ ๋จน์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ž…์ถœ๋ ฅ ์˜ˆ #3 4๋ช…์ด ๋ชจ๋‘ ๊ฐ™์€ ์–‘์„ ๋จน๊ธฐ ์œ„ํ•ด ์ตœ์†Œ 2ํŒ์„ ์‹œํ‚ค๋ฉด ..

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/JS] ๋จธ์“ฑ์ด๋ณด๋‹ค ํ‚ค ํฐ ์‚ฌ๋žŒ

Problem Description ๋‘ ๋ฐฐ์—ด์ด ์–ผ๋งˆ๋‚˜ ์œ ์‚ฌํ•œ์ง€ ํ™•์ธํ•ด๋ณด๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ๋ฌธ์ž์—ด ๋ฐฐ์—ด s1๊ณผ s2๊ฐ€ ์ฃผ์–ด์งˆ ๋•Œ ๊ฐ™์€ ์›์†Œ์˜ ๊ฐœ์ˆ˜๋ฅผ returnํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด์ฃผ์„ธ์š”.๋จธ์“ฑ์ด๋Š” ํ•™๊ต์—์„œ ํ‚ค ์ˆœ์œผ๋กœ ์ค„์„ ์„ค ๋•Œ ๋ช‡ ๋ฒˆ์งธ๋กœ ์„œ์•ผ ํ•˜๋Š”์ง€ ๊ถ๊ธˆํ•ด์กŒ์Šต๋‹ˆ๋‹ค. ๋จธ์“ฑ์ด๋„ค ๋ฐ˜ ์นœ๊ตฌ๋“ค์˜ ํ‚ค๊ฐ€ ๋‹ด๊ธด ์ •์ˆ˜ ๋ฐฐ์—ด array์™€ ๋จธ์“ฑ์ด์˜ ํ‚ค height๊ฐ€ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์งˆ ๋•Œ, ๋จธ์“ฑ์ด๋ณด๋‹ค ํ‚ค ํฐ ์‚ฌ๋žŒ ์ˆ˜๋ฅผ return ํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด๋ณด์„ธ์š”. Restrictions 1 ≤ array์˜ ๊ธธ์ด ≤ 100 1 ≤ height ≤ 200 1 ≤ array์˜ ์›์†Œ ≤ 200 Input/Output Example ์ž…์ถœ๋ ฅ ์˜ˆ #1 149, 180, 192, 170 ์ค‘ ๋จธ์“ฑ์ด๋ณด๋‹ค ํ‚ค๊ฐ€ ํฐ ์‚ฌ๋žŒ์€ 1..

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/JS] ์ตœ๋Œ“๊ฐ’ ๋งŒ๋“ค๊ธฐ (1)

Problem Description ์ •์ˆ˜๊ฐ€ ๋‹ด๊ธด ๋ฐฐ์—ด array์™€ ์ •์ˆ˜ n์ด ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์งˆ ๋•Œ, array์— n์ด ๋ช‡ ๊ฐœ ์žˆ๋Š” ์ง€๋ฅผ return ํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด๋ณด์„ธ์š”. Restrictions 1 ≤ array์˜ ๊ธธ์ด ≤ 100 0 ≤ array์˜ ์›์†Œ ≤ 1,000 0 ≤ n ≤ 1,000 Input/Output Example ์ž…์ถœ๋ ฅ ์˜ˆ #1 [1, 1, 2, 3, 4, 5] ์—๋Š” 1์ด 2๊ฐœ ์žˆ์Šต๋‹ˆ๋‹ค. ์ž…์ถœ๋ ฅ ์˜ˆ #2 [0, 2, 3, 4] ์—๋Š” 1์ด 0๊ฐœ ์žˆ์Šต๋‹ˆ๋‹ค. My solution function solution(numbers) { const sortArray = numbers.sort((a, b) => b-a) return sortArray[0] * sortArray[1..

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/JS] ๋ฐฐ์—ด์˜ ์œ ์‚ฌ๋„

Problem Description ๋‘ ๋ฐฐ์—ด์ด ์–ผ๋งˆ๋‚˜ ์œ ์‚ฌํ•œ์ง€ ํ™•์ธํ•ด๋ณด๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ๋ฌธ์ž์—ด ๋ฐฐ์—ด s1๊ณผ s2๊ฐ€ ์ฃผ์–ด์งˆ ๋•Œ ๊ฐ™์€ ์›์†Œ์˜ ๊ฐœ์ˆ˜๋ฅผ returnํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด์ฃผ์„ธ์š”. Restrictions 1 ≤ s1, s2์˜ ๊ธธ์ด ≤ 100 1 ≤ s1, s2์˜ ์›์†Œ์˜ ๊ธธ์ด ≤ 10 s1๊ณผ s2์˜ ์›์†Œ๋Š” ์•ŒํŒŒ๋ฒณ ์†Œ๋ฌธ์ž๋กœ๋งŒ ์ด๋ฃจ์–ด์ ธ ์žˆ์Šต๋‹ˆ๋‹ค s1๊ณผ s2๋Š” ๊ฐ๊ฐ ์ค‘๋ณต๋œ ์›์†Œ๋ฅผ ๊ฐ–์ง€ ์•Š์Šต๋‹ˆ๋‹ค. Input/Output Example ์ž…์ถœ๋ ฅ ์˜ˆ #1 "b"์™€ "c"๊ฐ€ ๊ฐ™์œผ๋ฏ€๋กœ 2๋ฅผ returnํ•ฉ๋‹ˆ๋‹ค. ์ž…์ถœ๋ ฅ ์˜ˆ #2 ๊ฐ™์€ ์›์†Œ๊ฐ€ ์—†์œผ๋ฏ€๋กœ 0์„ returnํ•ฉ๋‹ˆ๋‹ค. My solution function solution(s1, s2) { return s1.filter(el => s2.includes(e..

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/JS] ์‚ผ๊ฐํ˜•์˜ ์™„์„ฑ์กฐ๊ฑด (1)

Problem Description ์„ ๋ถ„ ์„ธ ๊ฐœ๋กœ ์‚ผ๊ฐํ˜•์„ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด์„œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์กฐ๊ฑด์„ ๋งŒ์กฑํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๊ฐ€์žฅ ๊ธด ๋ณ€์˜ ๊ธธ์ด๋Š” ๋‹ค๋ฅธ ๋‘ ๋ณ€์˜ ๊ธธ์ด์˜ ํ•ฉ๋ณด๋‹ค ์ž‘์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์‚ผ๊ฐํ˜•์˜ ์„ธ ๋ณ€์˜ ๊ธธ์ด๊ฐ€ ๋‹ด๊ธด ๋ฐฐ์—ด sides์ด ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์ง‘๋‹ˆ๋‹ค. ์„ธ ๋ณ€์œผ๋กœ ์‚ผ๊ฐํ˜•์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋‹ค๋ฉด 1, ๋งŒ๋“ค ์ˆ˜ ์—†๋‹ค๋ฉด 2๋ฅผ returnํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด์ฃผ์„ธ์š”. Restrictions sides์˜ ์›์†Œ๋Š” ์ž์—ฐ์ˆ˜์ž…๋‹ˆ๋‹ค. sides์˜ ๊ธธ์ด๋Š” 3์ž…๋‹ˆ๋‹ค. 1 ≤ sides์˜ ์›์†Œ ≤ 1,000 Input/Output Example ์ž…์ถœ๋ ฅ ์˜ˆ #1 ๊ฐ€์žฅ ํฐ ๋ณ€์ธ 3์ด ๋‚˜๋จธ์ง€ ๋‘ ๋ณ€์˜ ํ•ฉ 3๊ณผ ๊ฐ™์œผ๋ฏ€๋กœ ์‚ผ๊ฐํ˜•์„ ์™„์„ฑํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ 2๋ฅผ returnํ•ฉ๋‹ˆ๋‹ค. ์ž…์ถœ๋ ฅ ์˜ˆ #2 ๊ฐ€์žฅ ํฐ ๋ณ€์ธ 6์ด ๋‚˜๋จธ์ง€ ๋‘ ..

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/JS] ๋ฌธ์ž ๋ฐ˜๋ณต ์ถœ๋ ฅํ•˜๊ธฐ

Problem Description ๋ฌธ์ž์—ด my_string๊ณผ ์ •์ˆ˜ n์ด ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์งˆ ๋•Œ, my_string์— ๋“ค์–ด์žˆ๋Š” ๊ฐ ๋ฌธ์ž๋ฅผ n๋งŒํผ ๋ฐ˜๋ณตํ•œ ๋ฌธ์ž์—ด์„ return ํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด๋ณด์„ธ์š”. Restrictions 2 ≤ my_string ๊ธธ์ด ≤ 5 2 ≤ n ≤ 10 "my_string"์€ ์˜์–ด ๋Œ€์†Œ๋ฌธ์ž๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ์Šต๋‹ˆ๋‹ค. Input/Output Example ์ž…์ถœ๋ ฅ ์˜ˆ #1 "hello"์˜ ๊ฐ ๋ฌธ์ž๋ฅผ ์„ธ ๋ฒˆ์”ฉ ๋ฐ˜๋ณตํ•œ "hhheeellllllooo"๋ฅผ return ํ•ฉ๋‹ˆ๋‹ค. My solution function solution(my_string, n) { return (my_string.split("").map((x) => x.repeat(n))).join('') } Anot..

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/JS] ๋ฌธ์ž์—ด์•ˆ์— ๋ฌธ์ž์—ด

Problem Description ์ •์ˆ˜ n์ด ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์งˆ ๋•Œ n์˜ ๊ฐ ์ž๋ฆฌ ์ˆซ์ž์˜ ํ•ฉ์„ returnํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด์ฃผ์„ธ์š” Restrictions 0 ≤ n ≤ 1,000,000 Input/Output Example ์ž…์ถœ๋ ฅ ์˜ˆ #1 1 + 2 + 3 + 4 = 10์„ returnํ•ฉ๋‹ˆ๋‹ค. ์ž…์ถœ๋ ฅ ์˜ˆ #2 9 + 3 + 0 + 2 + 1 + 1 = 16์„ returnํ•ฉ๋‹ˆ๋‹ค. My solution function solution(str1, str2) { return str1.includes(str2) ? 1 : 2 } Another solutions function solution(str1, str2) { return str1.split(str2).length > 1 ? 1 : 2 }..

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/JS] ์•„์ด์Šค ์•„๋ฉ”๋ฆฌ์นด๋…ธ

Problem Description๋จธ์“ฑ์ด๋Š” ์ถ”์šด ๋‚ ์—๋„ ์•„์ด์Šค ์•„๋ฉ”๋ฆฌ์นด๋…ธ๋งŒ ๋งˆ์‹ญ๋‹ˆ๋‹ค. ์•„์ด์Šค ์•„๋ฉ”๋ฆฌ์นด๋…ธ๋Š” ํ•œ์ž”์— 5,500์›์ž…๋‹ˆ๋‹ค. ๋จธ์“ฑ์ด๊ฐ€ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๋ˆ money๊ฐ€ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์งˆ ๋•Œ, ๋จธ์“ฑ์ด๊ฐ€ ์ตœ๋Œ€๋กœ ๋งˆ์‹ค ์ˆ˜ ์žˆ๋Š” ์•„๋ฉ”๋ฆฌ์นด๋…ธ์˜ ์ž” ์ˆ˜์™€ ๋‚จ๋Š” ๋ˆ์„ ์ˆœ์„œ๋Œ€๋กœ ๋‹ด์€ ๋ฐฐ์—ด์„ return ํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด๋ณด์„ธ์š”. Restrictions0  Input/Output Example์ž…์ถœ๋ ฅ ์˜ˆ #1 5,500์›์€ ์•„์ด์Šค ์•„๋ฉ”๋ฆฌ์นด๋…ธ ํ•œ ์ž”์„ ์‚ด ์ˆ˜ ์žˆ๊ณ  ์ž”๋ˆ์€ 0์›์ž…๋‹ˆ๋‹ค.์ž…์ถœ๋ ฅ ์˜ˆ #2 15,000์›์€ ์•„์ด์Šค ์•„๋ฉ”๋ฆฌ์นด๋…ธ ๋‘ ์ž”์„ ์‚ด ์ˆ˜ ์žˆ๊ณ  ์ž”๋ˆ์€ 4,000์›์ž…๋‹ˆ๋‹ค. My solutionfunction solution(money) {    return [Math.floor(money / 5500..

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/JS] ๋ฐฐ์—ด ์ž๋ฅด๊ธฐ

Problem Description ์ •์ˆ˜ ๋ฐฐ์—ด numbers์™€ ์ •์ˆ˜ num1, num2๊ฐ€ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์งˆ ๋•Œ, numbers์˜ num1๋ฒˆ ์งธ ์ธ๋ฑ์Šค๋ถ€ํ„ฐ num2๋ฒˆ์งธ ์ธ๋ฑ์Šค๊นŒ์ง€ ์ž๋ฅธ ์ •์ˆ˜ ๋ฐฐ์—ด์„ return ํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด๋ณด์„ธ์š”. Restrictions 2 ≤ numbers์˜ ๊ธธ์ด ≤ 30 0 ≤ numbers์˜ ์›์†Œ ≤ 1,000 0 ≤num1

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/JS] ๋ฐฐ์—ด ๋’ค์ง‘๊ธฐ

Problem Description ์ •์ˆ˜๊ฐ€ ๋“ค์–ด ์žˆ๋Š” ๋ฐฐ์—ด num_list๊ฐ€ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์ง‘๋‹ˆ๋‹ค. num_list์˜ ์›์†Œ์˜ ์ˆœ์„œ๋ฅผ ๊ฑฐ๊พธ๋กœ ๋’ค์ง‘์€ ๋ฐฐ์—ด์„ returnํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด์ฃผ์„ธ์š”. Restrictions 1 ≤ num_list์˜ ๊ธธ์ด ≤ 1,000 0 ≤ num_list์˜ ์›์†Œ ≤ 1,000 Input/Output Example ์ž…์ถœ๋ ฅ ์˜ˆ #1 num_list๊ฐ€ [1, 2, 3, 4, 5]์ด๋ฏ€๋กœ ์ˆœ์„œ๋ฅผ ๊ฑฐ๊พธ๋กœ ๋’ค์ง‘์€ ๋ฐฐ์—ด [5, 4, 3, 2, 1]์„ returnํ•ฉ๋‹ˆ๋‹ค. ์ž…์ถœ๋ ฅ ์˜ˆ #2 num_list๊ฐ€ [1, 1, 1, 1, 1, 2]์ด๋ฏ€๋กœ ์ˆœ์„œ๋ฅผ ๊ฑฐ๊พธ๋กœ ๋’ค์ง‘์€ ๋ฐฐ์—ด [2, 1, 1, 1, 1, 1]์„ returnํ•ฉ๋‹ˆ๋‹ค. My solution function solution..

๋ฐ˜์‘ํ˜•