๋ฐ์ํ ๐ ์๊ณ ๋ฆฌ์ฆ65 [LeetCode] 125_Palindrome ์ฒ์ ํ์ด ๋ฌธ์ ๋งํฌ 125_Valid Palindrome โ๏ธ ์ฒ์ ํ์ด var isPalindrome = function (s) { s = s.toUpperCase(); let ans = []; for (let i = 0; i = 'A' && s[i] = '0' && s[i] 2021. 12. 7. [LeetCode] 28_ImplementstrStr -JavaScript ๋ฌธ์ ๋งํฌ : 28_ImplementstrStr string ๋ฌธ์ haystack๊ณผ needle์ด ์ฃผ์ด์ก์ ๋ needle์ด haystack์ ์๋์ง ํ์ธํ๊ณ ์์ผ๋ฉด ํด๋น idx๋ฅผ ์์ผ๋ฉด -1์ returnํ๋ค. โ๏ธ ์ฒ์ ํ์ด var strStr = function (haystack, needle) { let needleLen = needle.length; for (let i = 0; i < haystack.length; i++) { if (haystack[i] === needle[0]) { if (haystack.substring(i, i + needleLen) === needle) return i; } } } haystack์ ๊ฐ์๋งํผ for๋ฌธ์ ๋๋ฉฐ ๊ทธ ์ฒซ ๊ธ์๊ฐ ๊ฐ๋ค๋ฉด needle์๊ธธ์ด๋งํ์ ๋ฌธ.. 2021. 12. 2. [LeetCode] 64 _ minimumPathSum ๋์ ํ์ด var minPathSum = function (grid) { let mLen = grid.length; let nLen = grid[0].length; const DP = [...new Array(mLen)].map(() => []); DP[0][0] = grid[0][0]; for (let i = 0; i < mLen; i++) { for (let j = 0; j < nLen; j++) { if (i === 0 && j === 0) DP[i][j] = grid[i][j]; // ์ฐ์ธก ๋ฐฉํฅ else if (j === 0) DP[i][j] = grid[i][j] + DP[i - 1][j]; // ํ๋จ ๋ฐฉํฅ else if (i === 0) DP[i][j] = grid[i][j] + DP[i][j.. 2021. 11. 23. [LeetCode] 746 Min Cost Climbing Stairs-javascript ๋์ ํ์ด var minCostClimbingStairs = function(cost) { const goalStair = cost.length let DP=[] DP[0] = 0; DP[1] = 0; DP[2] = Math.min(cost[0],cost[1]) for (let i=3 ; i 2021. 11. 20. [๋ฐฑ์ค] node.js/ 2606_๋ฐ์ด๋ฌ์ค ์ด๋ฒ ๋ฌธ์ ๋ ์ฝ์ง ์์๋ค. dfs๋ฅผ ์ด์ฉํด ํ์ดํ๋ ๋ฌธ์ ์๊ณ , ๋๋ dfs์ ์์ง ์ฝํ๊ธฐ ๋๋ฌธ์ ๋ ๋ง์ด ๊ณต๋ถํด์ผ ํ๋คใ . ์ ๋ต ํ์ด n+1์ ํ๋ ์ด์ ๋ ์ธ๋ฑ์ค์ ์๋ฅผ ๋ง์ถฐ์ฃผ๊ธฐ ์ํด์! ( 0 idx์ ๊ฐ์ ์ฐ์ง ์๋๋ค๊ณ ๋ณด๋ฉด ๋๋ค.) const fs = require('fs'); let input = (fs.readFileSync('./dev/stdin') + '').toString().trim().split('\n'); let n = Number(input.shift()); let m = Number(input.shift()); let graph = [...new Array(n + 1)].map(() => []); let visited = new Array(n + 1).fill(false); let.. 2021. 11. 7. [๋ฐฑ์ค] node.js/ 1463_1๋ก ๋ง๋ค๊ธฐ ๋ฌธ์ ๋ฅผ ๋ณด์๋ง์ ๋๋์ด ์๋ค. ์ ์ด๊ฑฐ.. ์๊ณ ๋ฆฌ์ฆ์ด ํ์ํ๋ค!!!!! ์ฒ์์๋ 3๋ถํฐ ๋๋๊ณ , 2๋ถํฐ๋๋๊ณ -1 ํ๋ฉด ๋์ง ๋ผ๊ณ ์๊ฐํ๋๋ฐ ์ฒ๋ง์ ๋ง์~ ํํธ์ ๋กํ๋ ๋์ ์๋ ๊ฐ๋ฅด์นจ์ ๋ณด๊ณ ๋ฐ๋ก ๋๋ ธ๋ค. ์ฐธ๊ณ ํ์ด const fs = require('fs'); let n = (fs.readFileSync('./dev/stdin') + '').toString().trim(); n = Number(n); const DP = new Array(n + 1).fill(0); for (let i = 2; i 2021. 10. 27. ๋ฐฑ์ค] node.js/ 1448_ ์ผ๊ฐํ ๋ง๋ค๊ธฐ ๋ด ํ์ด (์๊ฐ์ด๊ณผ) const fs = require('fs'); let input = (fs.readFileSync('./dev/stdin') + '').toString().trim().split('\n'); const n = +input.shift(); let sumArr = []; input = input.map((line) => parseInt(line)); input.sort((a, b) => parseInt(b) - parseInt(a)); const checkTri = (a, b, c) => { return a < b + c; }; for (let i = 0; i < n - 2; i++) { if (checkTri(input[i], input[i + 1], input[i + 2])) { a.. 2021. 10. 23. [๋ฐฑ์ค] node.js/ 1748_ ์ ์ด์ด์ฐ๊ธฐ(1) ๋ดํ์ด const fs = require('fs'); let input = (fs.readFileSync('./dev/stdin') + '').toString().trim(); const lenInput = input.length; let cnt = 0; // 1 2 3 // 10-1 100-10 + 120-(100-1) for (let i = 1; i 2021. 10. 22. [๋ฐฑ์ค] node.js/ 15650 N๊ณผM(2) ๋ด ํ์ด const fs = require('fs'); let [n, m] = (fs.readFileSync('./dev/stdin') + '').toString().trim().split(' '); let visit = new Array(parseInt(n)).fill(false); n = parseInt(n); m = parseInt(m); let ans = []; const back = (d, n, m, idx) => { if (d === m) { console.log(...ans); return; } for (let i = idx; i < n; i++) { if (visit[i]) continue; visit[i] = true; ans.push(i + 1); back(d + 1, n, m, i);.. 2021. 10. 21. ์ด์ 1 2 3 4 ยทยทยท 8 ๋ค์ ๋ฐ์ํ