본문 바로가기

코딩 테스트/프로그래머스 코딩테스트

(26)
문자열을 정수로 바꾸기 https://school.programmers.co.kr/learn/courses/30/lessons/12925?language=cpp 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 요게 제 풀이입니다.#include #include #include using namespace std;int solution(string s) { int answer = 0; int tens = 0; if(s[0] == '-') { for(int i=s.size()-1; i>0; i--) { answer..
문자열 내 p와 y의 개수 https://school.programmers.co.kr/learn/courses/30/lessons/12916 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr #include #include using namespace std;bool solution(string s){ bool answer = true; short p_size = 0; short y_size = 0; for(int i=0; i 통과!
영어 끝말잇기 https://school.programmers.co.kr/learn/courses/30/lessons/12981# 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include using namespace std; vector solution(int n, vector words) { vector answer; int personNum = 0; int personOrder = 0; for(int i=1; i
[미해결] 괄호 회전하기 https://school.programmers.co.kr/learn/courses/30/lessons/76502# 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include #include using namespace std; int solution(string s) { int answer = -1; queue strQueue; int length = s.length(); // string to queue for(int i=0; i
다리를 지나는 트럭 https://school.programmers.co.kr/learn/courses/30/lessons/42583 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include #include using namespace std; struct TRUCK_INFO{ int weight = 0; int time = 0; }; int solution(int bridge_length, int weight, vector truck_weights) { int answer = 0; // Vector vector truck_wait; /..
다음 큰 숫자 #include #include #include #include #include using namespace std; int getBinOneAmount(int n) { vector binVector; // 이진법 변환 int bin = 0; while(n >= 1) { bin = n % 2; n = n / 2; // cout
숫자의 표현 #include #include #include using namespace std; int solution(int n) { int answer = 0; int sum = 0; int stopNum = n / 2; stopNum++; cout
[1차] 다트 게임 https://school.programmers.co.kr/learn/courses/30/lessons/17682# 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include #include using namespace std; int solution(string dartResult) { int answer = 0; // cout
JadenCase 문자열 만들기 내 풀이 #include #include using namespace std; #define ALPHABET_TRANS 32 string solution(string s) { string answer = ""; int i=0; bool bSpaceFlag = false; while(s[i]) { // 모든 문자에 해당, 대문자 -> 소문자 if(s[i] >= 'A' && s[i] 대문자 if(s[0] >= 'a' && s[0] 대문자 if((s[i] >= 'a' && s[i] = '0' && s[i] 삼항조건 연산자 공부 필요! s[i-1] == ' ' 여기서는 이전 문자가 공백인지 아닌지를 체크를 하고 공백이라면 1(true)을 출력, 아니라면 0(false)을 출력합니다. answer += toupp..
최솟값 만들기 #include #include #include using namespace std; int solution(vector A, vector B) { int answer = 0; sort(A.begin(), A.end()); sort(B.rbegin(), B.rend()); // Sum for(int i=0; i