본문 바로가기

전체 글

(167)
[프로그래머스] 같은 숫자는 싫어 (JS) 문제 https://school.programmers.co.kr/learn/courses/30/lessons/12906 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 코드 function solution(arr){ const answer = []; arr.forEach(a => { if(answer.length===0 || answer[answer.length-1]!==a) answer.push(a); }) return answer; } 정리 JS에서 배열에 마지막 원소를 접근하고 싶을 때 answer[answer.length-1] answer[-1]로는..
[프로그래머스] H-Index (JS) - sort 문제 https://school.programmers.co.kr/learn/courses/30/lessons/42747 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 코드 내 풀이 function solution(citations) { citations.sort((a,b)=>a-b); let h=0; for (let i=citations[citations.length-1]; i>=0; i--){ if(citations.filter(n => n>=i).length>=i){ h=i; break; } } return h; } for문 안에 filter로 한 번..
[프로그래머스] 가장 큰 수 (JS) - sort 문제 https://school.programmers.co.kr/learn/courses/30/lessons/42746 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 코드 function solution(numbers) { const answer = numbers.map(n => String(n)).sort((a,b) => (b+a)-(a+b)).join(''); return answer[0]==='0' ? '0':answer; } 정리 string으로 대소 비교를 하기 위해 map을 사용해 원소를 string type으로 변경해준다. const answ..
[프로그래머스] K번째수 (JS) - sort 문제 https://school.programmers.co.kr/learn/courses/30/lessons/42748 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 코드 function solution(array, commands) { const answer = []; const length = commands.length; for (let command of commands){ const [i,j,k] = command; const temp = array.slice(i-1,j) temp.sort((a,b)=>(a-b)) answer.push(temp[..
[프로그래머스] 소수 찾기 (JS) - 완전탐색, DFS 문제 https://school.programmers.co.kr/learn/courses/30/lessons/42839 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 코드 function solution(numbers){ const answer = []; const nums = numbers.split(''); const length = nums.length; const isVisited = Array.from({length:length}, ()=>false); const arr = Array.from({length:length}, ()=>0); func..
[프로그래머스] 모의고사 (JS) - 완전탐색 문제 https://school.programmers.co.kr/learn/courses/30/lessons/42840 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 코드 function solution(answers) { const answer = []; const user1 = [1,2,3,4,5]; const user2 = [2,1,2,3,2,4,2,5]; const user3 = [3,3,1,1,2,2,4,4,5,5]; const user1Length = user1.length; const user2Length = user2.length; cons..
[프로그래머스] 신고 결과 받기 (C++, JS) 문제 https://school.programmers.co.kr/learn/courses/30/lessons/92334 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 코드 C++ #include #include #include #include using namespace std; map reportingIds; map reportedNums; vector solution(vector id_list, vector report, int k) { vector answer; sort(report.begin(), report.end()); report.erase(..
[소프트웨어 마에스트로] 최종 프로젝트 점검을 앞두고 소마 회고 블로그에 오랜만에 글을 쓴다. 소프트웨어 마에스트로에 합격하고 나서 이것저것 활동하느라 시간이 엄청 빠르게 흘러갔다. 소마 정규 일정도 막바지에 다다른 지금 소마에 합격하고나서부터 지금까지의 일을 정리해보고자 한다. 4월 - 오리엔테이션, 팀 매칭 오리엔테이션 4월에는 소마의 첫 행사인 오리엔테이션을 진행했다. 10, 11명씩 테이블이 나누어져있었고 4,5명씩 한 팀을 이루었다. 오리엔테이션에서 첫 활동은 레고를 활용해 자기소개하기와 테이블별로 소프트웨어마에스트로?를 나타내는 구조물을 만들었다. 팀원들과 어색함을 깨고 협력을 다지라는 차원에서 진행한 활동인 것 같다. 저녁부터 다음날 아침까지는 아이디어톤을 했다. 우리 팀은 여행 동행 플랫폼 아이디어로 아이디어톤을 준비했다. 이렇게 해서 1박 2일 간 오..