#프로그래머스 #1단계 #C++ 59

프로그래머스 - 최소 직사각형 - 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..

프로그래머스 - 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

프로그래머스 - K번째수 - C++

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

프로그래머스 - 약수의 개수와 덧셈 - C++

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

프로그래머스 - 시저 암호 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/12926 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include using namespace std; string solution(string s, int n) { for(int i=0;i= 97) { al = (al - 97 + n) % 26; s[i] = 'a'+al; } else { al = (al - 65 + n) % 26; s[i] = 'A' + al; } } } return s; } 설명 이 문제는 문자열에 있는 알파..

프로그래머스 - 이상한 문자 만들기 - C++

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

프로그래머스 - 문자열 내림차순 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/12917 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include using namespace std; bool compare(int a,int b) { if(a>b) return true; else return false; } string solution(string s) { sort(s.begin(),s.begin()+s.length(),compare); return s; } 설명 이 문제는 주어진 문자열을 내..