전체 글 203

프로그래머스 - 신규 아이디 추천 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/72410 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr #include #include #include using namespace std;string solution(string new_id) { string answer = ""; // 대문자를 소문자로 치환 for (int i = 0; i = 'A' && new_id[i] = 'a' && new_id[i] = '0' && new_id[i] = 16) answer.erase..

프로그래머스 - 개인정보 수집 유효기간 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/150370 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr #include #include #include using namespace std;vector solution(string today, vector terms, vector privacies) { vector answer; map m; int year = stoi(today.substr(0,4)); int month = stoi(today.substr(5,2)); int..

프로그래머스 - 둘만의 암호 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/155652 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr #include #include using namespace std;string solution(string s, string skip, int index) { string answer = ""; for(int i=0;i122)s[i]-=26; bool b=false; for(int j=0;j 주어진 문자열 s에서 index만큼 알파벳을 증가..

프로그래머스 - 숫자 짝꿍 - C++

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

프로그래머스 - 소수찾기 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/12921 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr #include #include using namespace std;int solution(int n) { int answer = 0; vector arr(n+1,true); for(int i=2;i*i 주어진 n까지의 수 중에서 소수가 몇개인지 찾는 문제이다.기존에 적용했던 소수판별 알고리즘으로 접근했을 때 효율성 문제에서 시간초과가 떠서 실패했다.  chatgpt에..

프로그래머스 - 소수 만들기 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/12977 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr #include #include using namespace std;bool isprim(int n){ int cnt=0; for(int i=1;i*i nums) { int answer = 0; for(int i=0;i 주어진 int 형 벡터에서 서로다른 3개를 뽑아더한 값이 소수인지를 판단하는 것이다. 최대 몇개의 소수를 만들 수 있는가를 구하는 문제이다.  경우의 수를 구하는..

프로그래머스 - 기사단원의 무기 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/136798 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr #include #include using namespace std;int solution(int number, int limit, int power) { int answer = 0; for(int i=1;ilimit) cnt=power; answer+=cnt; } return answer;} 간단히 number까지의 수들 각각에 ..

프로그래머스 - 모의고사 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/42840 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr #include #include using namespace std;vector solution(vector answers) { vector answer; int a1[5]={1,2,3,4,5}; int a2[8]={2,1,2,3,2,4,2,5}; int a3[10]={3,3,1,1,2,2,4,4,5,5}; int cnt1=0,cnt2=0,cnt3=0; ..

프로그래머스 - 2016 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/12901#qna 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr #include #include using namespace std;string solution(int a, int b) { string answer = ""; int month[13] = { 0,31,29,31,30,31,30,31,31,30,31,30,31 }; string d[7] = { "THU","FRI","SAT","SUN","MON","TUE","WED" }; ..

프로그래머스 - 폰켓몬 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/1845 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr #include #include using namespace std;int solution(vector nums){ int answer = 0; map m; for(int i=0;i=nums.size()/2)break; answer++; } return answer;} 종류에 따라 폰켓몬에 번호가 부여되는데 번호로 이루어진 배열이 주어진다.이 때, ..