본문 바로가기

Coding Test/Programmers175

[Programmers] (2021 KAKAO BLIND RECRUITMENT) Lv 2. 메뉴 리뉴얼 https://school.programmers.co.kr/learn/courses/30/lessons/72411 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include #include using namespace std; void combination(set& set, const string& str, string res, int r, int next) { if (res.length() == r) { set.insert(res); return; } for (int i = next; i < str.length(); .. 2023. 8. 3.
[Programmers] (2022 KAKAO TECH INTERNSHIP) Lv 2. 두 큐 합 같게 만들기 https://school.programmers.co.kr/learn/courses/30/lessons/118667 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include #include #include using namespace std; int solution(vector queue1, vector queue2) { int answer = 0; long sum1 = ::accumulate(queue1.begin(), queue1.end(), 0), sum2 = ::accumulate(queue2.begin(), .. 2023. 8. 1.
[Programmers] [투포인터] Lv 2. 연속된 부분 수열의 합 https://school.programmers.co.kr/learn/courses/30/lessons/178870 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include using namespace std; #include #include using namespace std; vector solution(vector sequence, int k) { int s = 0, e = 0; int sum = sequence[0]; // 부분 수열의 합 int subLen = sequence.size() + 1; // 부분 수열의 길이 pa.. 2023. 7. 31.
[Programmers] Lv 2. 124 나라의 숫자 https://school.programmers.co.kr/learn/courses/30/lessons/12899 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include using namespace std; string solution(int n) { string answer = "", str = "412"; while (n) { answer = str[n % 3] + answer; if (n % 3 == 0) --n; // 3인 경우는 4로 표현하기 때문에 -1 n = n / 3; } return answer; } GitHub :.. 2023. 7. 28.
[Programmers] (월간 코드 챌린지 시즌1) Lv 2. 삼각 달팽이 https://school.programmers.co.kr/learn/courses/30/lessons/68645 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include #include using namespace std; vector solution(int n) { vector vec; const size_t size = n * (n + 1) / 2; // n = 4 => 1+2+3+4 = 10 size_t row = 0, col = 0, count = 1; /* n = 4 일 때 다음 배열을 먼저 생성 [ [0].. 2023. 7. 28.
[Programmers] (탐욕법(Greedy)) Lv 2. 큰 수 만들기 https://school.programmers.co.kr/learn/courses/30/lessons/42883 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include #include using namespace std; string solution(string number, int k) { string answer = ""; int start = 0, cnt = number.length() - k; while (answer.length() != cnt) { // end에서 구해야 할 남은 개수만큼 뺀 영역까지 최.. 2023. 7. 27.
[Programmers] Lv 2. 택배상자 https://school.programmers.co.kr/learn/courses/30/lessons/131704 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include #include using namespace std; int solution(vector order) { int answer = 0; stack s; priority_queue q(order.begin(), order.end()); for (size_t i = 0; i < order.size();) { const auto find = order[i.. 2023. 7. 26.
[Programmers] (월간 코드 챌린지 시즌1) Lv 2. 쿼드압축 후 개수 세기 https://school.programmers.co.kr/learn/courses/30/lessons/68936 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include using namespace std; typedef struct _POS { size_t x; size_t y; } POS; class QurdTree { public: QurdTree(POS pos, size_t cnt) : _pos(pos), _cnt(cnt) { } void operator()(const vector& arr, vector& answer, co.. 2023. 7. 25.
[Programmers] (완전탐색) Lv 2. 소수 찾기 https://school.programmers.co.kr/learn/courses/30/lessons/42839# 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include #include #include #include using namespace std; // 순열 void permutation(string& numbers, set& s, string str, int r) { if (!str.empty()) s.emplace(stoi(str)); if (r == numbers.length()) return; for.. 2023. 7. 24.
[Programmers] (정렬) Lv 2. 가장 큰 수 https://school.programmers.co.kr/learn/courses/30/lessons/42746 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include #include #include #include using namespace std; string solution(vector numbers) { ::sort(numbers.begin(), numbers.end(), [](auto a, auto b) { string strA = to_string(a); string strB = to_string(b).. 2023. 7. 24.