분류 전체보기

https://school.programmers.co.kr/learn/courses/30/lessons/12949# 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 나의 풀이 function solution(arr1, arr2) { let box = [] let result = [] let sum = 0 for(i=0; i
나의 풀이 function solution(cacheSize, cities) { if(!cacheSize) return cities.length * 5 let time = 0 cities.reduce((cache, city) => { if(cache.includes(city.toLowerCase())){ cache = cache.filter( x => x !== city.toLowerCase()) cache.push(city.toLowerCase()) time += 1 }else{ cache.push(city.toLowerCase()) time += 5 } return cache.length > cacheSize ? cache.slice(1) : cache },[]) return time } 원래는 fu..
https://school.programmers.co.kr/learn/courses/30/lessons/12980# 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 나의 풀이 function solution(n){ let result = 1 // 무조건 처음에 점프 한 번은 해줘야한다. while(n > 1){ if(n%2 === 0) n /= 2 else{ n -= 1 result++ } } return result; } 처음에는 감이 안 잡혔는데 역시 몇번 대입해봐야 뭔가가 보인다. n = 4 일때는 1 2 2 result = 1 이다. n = 5 일때..
https://school.programmers.co.kr/learn/courses/30/lessons/12914 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 나의 풀이 function solution(n) { const dp = [0,1,2]; for(i=3; i
https://school.programmers.co.kr/learn/courses/30/lessons/12945 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 나의 풀이 function solution(n) { const dp = [0,1,1] for (i=3; i
https://school.programmers.co.kr/learn/courses/30/lessons/12985# 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 나의 풀이 function solution(n,a,b){ if(a n/2 ) return solution(n,a-(n/2),b-(n/2)) else if( a > n/2 && b n/2 && b n/2 && b > n/2이기 때문이다. 이걸 해결을 안 해줘서 계속 제출해도 반타작만 나왔었다. a > n/2 && b > n/2 일때 return solution (n/2, a,b)를 해준다면 여기서..
Array.prototype.at() 평소에 배열의 마지막이 필요할때 Array[Arrary.length - 1]을 해서 귀찮고 가독성이 떨어졌는데 주말에 심심해서 node.js 16.xxx 변동로그를 쭉보다가 Array.at()을 발견했다. 배열 뒷자리를 나타낼때 너무 편해보였다. 사용법은 간단하다. const array1 = [ 1, 2, 3, 4, 5, 6] console.log(array1.at(-1)) // 6 이렇게 작성하면 된다. 양수를 넣어주면 앞에서부터 카운트 되고 음수를 넣어주면 뒤에서부터 카운트 된다. 주어진 인덱스가 배열에 없으면 undefined를 반환한다. const array1 = [ 1, 2, 3, 4, 5, 6] console.log(array1.at(true)) // 2 ..
https://school.programmers.co.kr/learn/courses/30/lessons/12953# 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 나의 풀이 1) reduce 사용 function solution(arr) { const gcd = (a,b) =>{ const remainder = a%b; if( remainder === 0) return b; return gcd(b, remainder) } return arr.reduce((a,b) => a*b / gcd(a,b)) } 이 문제의 핵심은 3개를 초과하는 여러 수의 최소공배수..
https://school.programmers.co.kr/learn/courses/30/lessons/42885 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 나의 풀이 function solution(people, limit) { people.sort((a,b) => b - a) let Maxboat = [] let box = [] people.map(x => x > limit/2 ? Maxboat.push([x]) :box.push(x)) for(i=0, k=Maxboat.length - 1; i
개발자성장기
'분류 전체보기' 카테고리의 글 목록 (19 Page)