본문 바로가기

Coding Test/Programmers188

[Programmers] (완전탐색) Lv 2. 전력망을 둘로 나누기 https://school.programmers.co.kr/learn/courses/30/lessons/86971 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr const bfs = (graph, pivot, visited, vistedDuplication) => { const queue = [pivot]; let cnt = 0; while (queue.length) { const dest = queue.shift(); if (vistedDuplication[dest]) return Infinity; (visited[dest] = true), ++cnt;.. 2023. 8. 8.
[Programmers] (2020 KAKAO BLIND RECRUITMENT) Lv 2. 괄호 변환 https://school.programmers.co.kr/learn/courses/30/lessons/60058 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include using namespace std; // 문자열을 분리해서 u를 균형잡힌 문자열로, 나머지를 v로 뱉어주는 함수 void Balance(const string& p, string& outputU, string& outputV) { size_t open{ 0 }, close{ 0 }; for (size_t i = 0; i < p.length(); ++i) { p[i.. 2023. 8. 7.
[Programmers] (2018 KAKAO BLIND RECRUITMENT) Lv 2. [3차] 방금그곡 https://school.programmers.co.kr/learn/courses/30/lessons/17683 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include #include #include using namespace std; enum MusicInfo { S, E, TITLE, MELODY, }; void revertM(string& m) { // # 먼저 체크하기 위해 역으로 체크 for (auto rit = m.rbegin(); rit != m.rend(); rit++) { if (*rit == '.. 2023. 8. 7.
[Programmers] Lv 2. 무인도 여행 https://school.programmers.co.kr/learn/courses/30/lessons/154540 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include using namespace std; int dfs(int x, int y, vector& visited, const vector& dir, const vector& maps) { int value = maps[x][y] - '0'; visited[x][y] = true; for (const auto& d : dir) { int tx = x + d.. 2023. 8. 5.
[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.