분류 전체보기 226

프로그래머스 - 숫자 문자열과 영단어 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/81301 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr #include #include #include using namespace std;int solution(string s) { int answer = 0; map m; m.insert({"one",1}); m.insert({"two",2}); m.insert({"three",3}); m.insert({"four",4}); m.insert({"five",5}); ..

프로그래머스 - 두 개 뽑아서 더하기 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/68644 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr #include #include #include #include using namespace std;vector solution(vector numbers) { vector answer; map m; for(int i=0;i 주어진 정수 배열에 대해서 두 수를 뽑아서 더해 만들 수 있는 모든 수를 answer에 넣고 반환하느 문제이다.  따라서 이중반복문을 사용하며 각각의 수는 맵을 ..

프로그래머스 - 가장 가까운 글자 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/142086 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr #include #include using namespace std;vector solution(string s) { vector answer; int arr[26]; for(int i=0;i 주어진 문자열 s 에서 각 문자가 처음 나온건지 또 처음이 아니라면 가장 최근에 몇개의 문자 앞에서 나왔는지를 판단해서 answer에 삽입하는 문제이다. apple 이라면 -1,-1,1,-1,..

프로그래머스 - 최대공약수와 최소공배수 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/12940 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr #include #include using namespace std;vector solution(int n, int m) { vector answer; int a = (n>m)? m : n; for(int i=a; i>=1;i--) { if(n%i==0 && m%i==0) { answer.push_back(i); brea..

프로그래머스 - 최소 직사각형 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/86491?language=cpp 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr  #include #include using namespace std;int solution(vector> sizes) { int answer = 0; int w=1001,h=1001; for(int i=0;i 최소직사각형 문제는 모든 명함을 수납할 수 있는 가장 작은 수납함의 크기를 계산하는 문제이다.명함은 회전시켜서 수납할 수 있다. 2차원 벡터로 각 명함의..

프로그래머스 - 예산 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/12982 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 설명주어진 예산을 최대한 많은 부서에게 지원한다면 몇개의 부서에 지원가능한지를 묻는 문제이다.여기서 조건은 예산지원을 신청한 부서에게는 그 만큼의 예산을 반드시 줘야하기 때문에 그보다 모자라면 지원이 불가하다.따라서 지원금액이 낮은 부서부터 순서대로 지원하면 된다. #include #include #include #include #include using namespace std;int solutio..

Git 협업을 위한 Branch 정리

git 을 사용해 팀 프로젝트를 진행하는데 main 브랜치로 바로 작업 후 커밋 푸시를 하게 되면 내가 실수했을 때 모든 팀원에게 영향이 간다. 그래서 branch라는 것을 발견했고 알아보았다. 나뭇가지라는 의미로 워크트리에서 잔가지를 친다고 생각하면 된다. 현재 커밋지점에서 분기를 만들어서 내가 따로 기능을 수정하거나 추가, 삭제를 진행한다. 그리고 모두가 공유하고 있는 main 브랜치에 병합할 수 있다. 따라서 중간 중간 저장하고 싶을 때 마음대로 커밋을 해도 다른 팀원에게 영향가지 않는다. https://git-school.github.io/visualizing-git/ Visualizing Git git-school.github.io 이 사이트에서 연습해볼 수 있다. 사용법 git branch t..

개발 지식 2024.02.27

프로그래머스 - 3진법 뒤집기 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/68935 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include using namespace std; int solution(int n) { int answer = 0; string a=""; while(n>0) { a+=(char)(n%3); n/=3; } answer=0; int pow=1; for(int i=a.length()-1;i>=0;i--) { answer += (int)a[i]*pow; pow*=3..

프로그래머스 - 크기가 작은 부분 문자열 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/147355#qna 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include using namespace std; int solution(string t, string p) { long long answer = 0; long long pi = stoll(p); for(int i=0;i

프로그래머스 - 삼총사 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/131705 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include using namespace std; int answer = 0; void recur(vector number, int cnt, int num, int index) { if (cnt!=3&&index >= number.size())return; if (cnt == 3) { //cout