์•Œ๊ณ ๋ฆฌ์ฆ˜ & ๋ฌธ์ œํ’€์ด/Programmers-1

function setSortAndFliter(arr, arr2) { return arr.sort((a, b) => a - b).filter((v) => !arr2.includes(v)); } function solution(n, lost, reserve) { const noPeClothesStudent = setSortAndFliter(lost, reserve); const extraPeClothesStudent = setSortAndFliter(reserve, lost); for (const el of noPeClothesStudent) { const extraUniformidx = extraPeClothesStudent.findIndex( (value) => value === el - 1 || va..
ํ’€์ด ๐Ÿ™Ž๐Ÿป‍โ™‚๏ธ function solution(participant, completion) { participant.sort(); completion.sort(); for (let i = 0; i
ํ’€์ด1 ๐Ÿ™Ž๐Ÿป‍โ™‚๏ธ //ํ’€์ด 1 function solution(nums) { const numberOfAllCases = getCombinations(nums, 3).map((innerArr) => innerArr.reduce((acc, cur) => acc + cur, 0) ); let result = 0; numberOfAllCases.map((v) => { if (primeNumber(v)) result++; }); return result; } const primeNumber = (x) => { for (let i = 2; i { const result = []; if (arrLength === 1) return arr.map((el) => [el]); arr.map((item, idx, this..
ํ’€์ด ๐Ÿ™Ž๐Ÿป‍โ™‚๏ธ function solution(answer) { const result = []; const personOne = [1, 2, 3, 4, 5]; const personTwo = [2, 1, 2, 3, 2, 4, 2, 5]; const personThree = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5]; const answerOne = answer.filter((v, i) => v === personOne[i % 5]).length; const answerTwo = answer.filter((v, i) => v === personTwo[i % 8]).length; const answerThree = answer.filter((v, i) => v === personThree[i..
ํ’€์ด๐Ÿ™Ž๐Ÿป‍โ™‚๏ธ function solution(nums) { const numsSetSize = new Set(nums).size; const numsHalfCount = nums.length / 2; return numsSetSize > numsHalfCount ? numsHalfCount : numsSetSize; } /* (ํ’€์ด) ์ฃผ์–ด์ง„ ๋ฐฐ์—ด์„ Set ๊ฐ์ฒด๋กœ ๋ณ€ํ™˜ํ•˜์—ฌ ์ค‘๋ณต์„ ์ œ๊ฑฐํ•ด์ฃผ๊ณ  numsSetSize๊ฐ€ nums์˜ ๊ฐœ์ˆ˜ / 2 ๋ณด๋‹ค ๋งŽ์œผ๋ฉด nums.length์˜ ์ ˆ๋ฐ˜์ธ numsHalfCount๋ฅผ ๋ฆฌํ„ดํ•ด์ฃผ๊ณ  ์•„๋‹ˆ๋ฉด numsSetSize๋ฅผ ๋ฆฌํ„ดํ•ด์ค€๋‹ค. ์†”์งํžˆ ๋˜ ํžˆ๋“ ์ผ€์ด์Šค๊ฐ€ ์žˆ๋‹ค๋˜๊ฐ€ ํ•ด์„œ ์‹คํŒจํ•  ์ค„ ์•Œ์•˜๋Š”๋ฐ ํ†ต๊ณผ๋๋‹ค. ํ…Œ์ŠคํŠธ์˜ ์ด๋ฆ„์„ ๋ณด๋‹ˆ ํ•ด์‹œ์ธ๋ฐ ๊ด€๋ จ ์ž๋ฃŒ๋ฅผ ์ฐพ์•„๋ณด๋‹ˆ ํ•ด์‹œ๋Š” ์ž„์˜์˜ ๊ธธ์ด์˜ ๋ฐ์ดํ„ฐ๋ฅผ..
ํ’€์ด ๐Ÿ™Ž๐Ÿป‍โ™‚๏ธ function solution(sizes) { const maxSizes = Math.max(...sizes.flat()); let secondMaxSizes = 0; for (el of sizes) { if (el[0] > el[1]) { if (el[1] > secondMaxSizes) { secondMaxSizes = el[1]; } } else { if (el[0] > secondMaxSizes) { secondMaxSizes = el[0]; } } } return maxSizes * secondMaxSizes; } ๋ถˆํ•„์š”ํ•œ if ๋ฌธ์ด ๋งŽ์•„๋ณด์ธ๋‹ค.. ํ”ผ๋“œ๋ฐฑ function solution(sizes) { const maxSize = Math.max(...sizes.flat());..
ํ’€์ด ๐Ÿ™Ž๐Ÿป‍โ™‚๏ธ function solution(s) { const strArr = s.split(" "); let result = ""; for (let i = 0; i < strArr.length; i++) { for (let j = 0; j < strArr[i].length; j++) { result += !(j % 2) ? strArr[i][j].toUpperCase() : strArr[i][j].toLowerCase(); } if (i < strArr.length - 1) { result += " "; } } return result; } /* (ํ’€์ด) ํžˆ๋“ ์ผ€์ด์Šค ํ•ด๊ฒฐ์— ์ •๋ง ๋งŽ์€ ์‹œ๊ฐ„์„ ๋ฒ„๋ ธ๋‹ค.. 2์ค‘ for๋ฌธ์œผ๋กœ split์œผ๋กœ ๋‚˜๋ˆ ์ค€ strArr ๋ฐฐ์—ด์š”์†Œ์˜ ๊ฐœ์ˆ˜๋งŒํผ ๋Œ๋ ค์ฃผ๊ณ  ๋‚ด๋ถ€ for๋ฌธ์—์„œ..
ํ’€์ด ๐Ÿ™Ž๐Ÿป‍โ™‚๏ธ function solution(arr) { return arr.filter((el, idx) => el !== arr[idx + 1]); } ํ•ด๋‹น ๋ฌธ์ œ๋Š” ์Šคํƒ/ํ ์ž๋ฃŒ๊ตฌ์กฐ๋ฅผ ์ด์šฉํ•ด ํ‘ธ๋Š” ํ’€์ด์˜€๋Š”๋ฐ ํ’€์ด์ž์ฒด๋Š” ์ข‹์ง€๋งŒ ๋ฌธ์ œ์˜๋„์— ๋งž์ง€์•Š๋‹ค. ์˜๋„์— ๋งž๋Š” ํ’€์ด์— ๋Œ€ํ•ด ์•Œ์•„๋ณด์ž. ๋ฌธ์ œ ์˜๋„์— ๋งž๋Š” ํ’€์ด function solution(arr) { const result = []; for (const el of arr) { const lastElement = result[result.length - 1]; if (lastElement !== el) result.push(el); } return result; } ์Šคํ„ฐ๋”” ๋ฆฌ๋”๋‹˜์ด ์˜ฌ๋ ค์ฃผ์‹  ํ’€์ด. ์Šคํƒ ๊ตฌ์กฐ๋ฅผ ๊ฐ€์ง„ ํ’€์ด๋‹ค. ๋‚˜๋Š” ์š”์†Œ๋ฅผ ๋นผ๊ณ  ๋„ฃ๋Š” ์ž‘์—…..
YunCow
'์•Œ๊ณ ๋ฆฌ์ฆ˜ & ๋ฌธ์ œํ’€์ด/Programmers-1' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก