본문 바로가기

자바스크립트80

[JS] 412. Fizz Buzz 조건문 기본 문제 if 문을 어떻게 사용하냐에 따라 속도나 비용의 효율을 높일 수 있겠다 https://leetcode.com/problems/fizz-buzz/ Fizz Buzz - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com /** * @param {number} n * @return {string[]} */ var fizzBuzz = function(n) { const ans = []; for (let i = 1; i 2022. 11. 16.
[JS] 1672. Richest Customer Wealth 이차원 배열의 연산 문제 map 과 reduce 를 사용해서 풀어보았다 https://leetcode.com/problems/richest-customer-wealth/ Richest Customer Wealth - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com /** * @param {number[][]} accounts * @return {number} */ var maximumWealth = function (accounts) { const wealths .. 2022. 11. 16.
[JS] 1480. Running Sum of 1d Array 배창현 님에게 추천받은 leetCode 를 시작해보려 한다 프리미엄은 추후 생각해보고 일단 easy 부터 풀어보자 테스트코드가 바로 나오고, 테스트코드 설정도 가능하며 다른 유저들의 풀이와 비교하여 내 풀이가 얼마나 효율적이고 빠른지를 아래처럼 보여준다 실행시간, 메모리 사용량 등을 보고 도전 욕구가 생긴다 재밌네! 도전해보자! var runningSum = function(nums) { const arr = []; let sum = 0; for (let i = 0; i < nums.length; i++) { sum += nums[i]; arr.push(sum); } return arr; }; 2022. 11. 15.
[백준 5555/javascript] 반지 이전 c++ 과 비교할겸 가볍게 풀어보았다 전에 c++ 로 풀이할때는 find 로 찾았지만 정규표현식을 사용하니 훨씬 간단하였다 https://www.acmicpc.net/problem/5555 5555번: 반지 당신은 N개의 반지를 가지고 있다. 각각의 반지는 대문자 10 문자로 이루어진 문자열이 새겨져 있다. 반지는 문자열의 시작과 끝이 연결된 형태로 문자가 새겨져 있다. 반지에 각인된 문자열을 www.acmicpc.net let input = []; const readline = require("readline").createInterface({ input: process.stdin, output: process.stdout, }); readline.on("line", (line) => { inpu.. 2022. 11. 2.