๋ฐ˜์‘ํ˜•

ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค 36

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

Problem Description ๋ฌธ์ž์—ด my_string์ด ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์งˆ ๋•Œ, my_string ์•ˆ์— ์žˆ๋Š” ์ˆซ์ž๋งŒ ๊ณจ๋ผ ์˜ค๋ฆ„์ฐจ์ˆœ ์ •๋ ฌํ•œ ๋ฆฌ์ŠคํŠธ๋ฅผ return ํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์ž‘์„ฑํ•ด๋ณด์„ธ์š”. Restrictions. 1 ≤ my_string์˜ ๊ธธ์ด ≤ 100 my_string์—๋Š” ์ˆซ์ž๊ฐ€ ํ•œ ๊ฐœ ์ด์ƒ ํฌํ•จ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. my_string์€ ์˜์–ด ์†Œ๋ฌธ์ž ๋˜๋Š” 0๋ถ€ํ„ฐ 9๊นŒ์ง€์˜ ์ˆซ์ž๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ์Šต๋‹ˆ๋‹ค. - - - Input/Output Example ์ž…์ถœ๋ ฅ ์˜ˆ #1 "hi12392"์— ์žˆ๋Š” ์ˆซ์ž 1, 2, 3, 9, 2๋ฅผ ์˜ค๋ฆ„์ฐจ์ˆœ ์ •๋ ฌํ•œ [1, 2, 2, 3, 9]๋ฅผ return ํ•ฉ๋‹ˆ๋‹ค. ์ž…์ถœ๋ ฅ ์˜ˆ #2 "p2o4i8gj2"์— ์žˆ๋Š” ์ˆซ์ž 2, 4, 8, 2๋ฅผ ์˜ค๋ฆ„์ฐจ์ˆœ ์ •๋ ฌํ•œ [2, 2, 4,..

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/JS] ๊ฐ€์žฅ ํฐ ์ˆ˜ ์ฐพ๊ธฐ

Problem Description ์ •์ˆ˜ ๋ฐฐ์—ด array๊ฐ€ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์งˆ ๋•Œ, ๊ฐ€์žฅ ํฐ ์ˆ˜์™€ ๊ทธ ์ˆ˜์˜ ์ธ๋ฑ์Šค๋ฅผ ๋‹ด์€ ๋ฐฐ์—ด์„ return ํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด๋ณด์„ธ์š”. Restrictions. 1 ≤ array์˜ ๊ธธ์ด ≤ 100 0 ≤ array ์›์†Œ ≤ 1,000 array์— ์ค‘๋ณต๋œ ์ˆซ์ž๋Š” ์—†์Šต๋‹ˆ๋‹ค. Input/Output Example ์ž…์ถœ๋ ฅ ์˜ˆ #1 1, 8, 3 ์ค‘ ๊ฐ€์žฅ ํฐ ์ˆ˜๋Š” 8์ด๊ณ  ์ธ๋ฑ์Šค 1์— ์žˆ์Šต๋‹ˆ๋‹ค. ์ž…์ถœ๋ ฅ ์˜ˆ #2 9, 10, 11, 8 ์ค‘ ๊ฐ€์žฅ ํฐ ์ˆ˜๋Š” 11์ด๊ณ  ์ธ๋ฑ์Šค 2์— ์žˆ์Šต๋‹ˆ๋‹ค. My solution function solution(array) { var answer = []; answer.push(Math.max(...array)) answer.push(arra..

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

Problem Description ์ •์ˆ˜ ๋ฐฐ์—ด numbers๊ฐ€ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์ง‘๋‹ˆ๋‹ค. numbers์˜ ์›์†Œ ์ค‘ ๋‘ ๊ฐœ๋ฅผ ๊ณฑํ•ด ๋งŒ๋“ค ์ˆ˜ ์žˆ๋Š” ์ตœ๋Œ“๊ฐ’์„ returnํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด์ฃผ์„ธ์š”. Restrictions. -10,000 ≤ numbers์˜ ์›์†Œ ≤ 10,000 2 ≤ numbers ์˜ ๊ธธ์ด ≤ 100. Input/Output Example ์ž…์ถœ๋ ฅ ์˜ˆ #1 ๋‘ ์ˆ˜์˜ ๊ณฑ์ค‘ ์ตœ๋Œ“๊ฐ’์€ -3 * -5 = 15 ์ž…๋‹ˆ๋‹ค. ์ž…์ถœ๋ ฅ ์˜ˆ #2 ๋‘ ์ˆ˜์˜ ๊ณฑ์ค‘ ์ตœ๋Œ“๊ฐ’์€ 10 * 24 = 240 ์ž…๋‹ˆ๋‹ค. My solution function solution(numbers) { numbers.sort((a, b) => a - b); const length = numbers.length; const posi..

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/JS] n์˜ ๋ฐฐ์ˆ˜ ๊ณ ๋ฅด๊ธฐ

Problem Description ๋ฌธ์ž์—ด my_string์ด ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์ง‘๋‹ˆ๋‹ค. my_string์•ˆ์˜ ๋ชจ๋“  ์ž์—ฐ์ˆ˜๋“ค์˜ ํ•ฉ์„ returnํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด์ฃผ์„ธ์š”.์ •์ˆ˜ n๊ณผ ์ •์ˆ˜ ๋ฐฐ์—ด numlist๊ฐ€ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์งˆ ๋•Œ, numlist์—์„œ n์˜ ๋ฐฐ์ˆ˜๊ฐ€ ์•„๋‹Œ ์ˆ˜๋“ค์„ ์ œ๊ฑฐํ•œ ๋ฐฐ์—ด์„ returnํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด์ฃผ์„ธ์š”. Restrictions. 1 ≤ n ≤ 10,000 1 ≤ numlist์˜ ํฌ๊ธฐ ≤ 100 1 ≤ numlist์˜ ์›์†Œ ≤ 100,000 Input/Output Example ์ž…์ถœ๋ ฅ ์˜ˆ #1 numlist์—์„œ 3์˜ ๋ฐฐ์ˆ˜๋งŒ์„ ๋‚จ๊ธด [6, 9, 12]๋ฅผ returnํ•ฉ๋‹ˆ๋‹ค. ์ž…์ถœ๋ ฅ ์˜ˆ #2 numlist์—์„œ 5์˜ ๋ฐฐ์ˆ˜๋งŒ์„ ๋‚จ๊ธด [10, 5]๋ฅผ returnํ•ฉ๋‹ˆ๋‹ค..

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/JS] ๋Œ€๋ฌธ์ž์™€ ์†Œ๋ฌธ์ž

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

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/JS] ์ง์ˆ˜๋Š” ์‹ซ์–ด์š”

Problem Description ์ •์ˆ˜ n์ด ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์งˆ ๋•Œ, n ์ดํ•˜์˜ ํ™€์ˆ˜๊ฐ€ ์˜ค๋ฆ„์ฐจ์ˆœ์œผ๋กœ ๋‹ด๊ธด ๋ฐฐ์—ด์„ returnํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด์ฃผ์„ธ์š”. Restrictions 1 ≤ n ≤ 100 Input/Output Example ์ž…์ถœ๋ ฅ ์˜ˆ #1 10 ์ดํ•˜์˜ ํ™€์ˆ˜๊ฐ€ ๋‹ด๊ธด ๋ฐฐ์—ด [1, 3, 5, 7, 9]๋ฅผ returnํ•ฉ๋‹ˆ๋‹ค. ์ž…์ถœ๋ ฅ ์˜ˆ #2 15 ์ดํ•˜์˜ ํ™€์ˆ˜๊ฐ€ ๋‹ด๊ธด ๋ฐฐ์—ด [1, 3, 5, 7, 9, 11, 13, 15]๋ฅผ returnํ•ฉ๋‹ˆ๋‹ค. My solution function solution(n) { let array = []; let i for (i = 0; i x%2 == 1) } Another solutions function solution(n) { var answer = [..

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/JS] ์ˆจ์–ด์žˆ๋Š” ์ˆซ์ž์˜ ๋ง์…ˆ (1)

Problem Description ๋ฌธ์ž์—ด my_string์ด ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์ง‘๋‹ˆ๋‹ค. my_string์•ˆ์˜ ๋ชจ๋“  ์ž์—ฐ์ˆ˜๋“ค์˜ ํ•ฉ์„ returnํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด์ฃผ์„ธ์š”. Restrictions 1 ≤ my_string์˜ ๊ธธ์ด ≤ 1,000 my_string์€ ์†Œ๋ฌธ์ž, ๋Œ€๋ฌธ์ž ๊ทธ๋ฆฌ๊ณ  ํ•œ์ž๋ฆฌ ์ž์—ฐ์ˆ˜๋กœ๋งŒ ๊ตฌ์„ฑ๋˜์–ด์žˆ์Šต๋‹ˆ๋‹ค. Input/Output Example ์ž…์ถœ๋ ฅ ์˜ˆ # "aAb1B2cC34oOp"์•ˆ์˜ ํ•œ์ž๋ฆฌ ์ž์—ฐ์ˆ˜๋Š” 1, 2, 3, 4 ์ž…๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ 1 + 2 + 3 + 4 = 10 ์„ returnํ•ฉ๋‹ˆ๋‹ค. ์ž…์ถœ๋ ฅ ์˜ˆ #2 "1a2b3c4d123Z"์•ˆ์˜ ํ•œ์ž๋ฆฌ ์ž์—ฐ์ˆ˜๋Š” 1, 2, 3, 4, 1, 2, 3 ์ž…๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ 1 + 2 + 3 + 4 + 1 + 2 + 3 = 16 ์„ returnํ•ฉ..

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/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..

๋ฐ˜์‘ํ˜•