본문 바로가기

코딩테스트187

[Programmers] (Summer/Winter Coding(~2018)) Lv 2. 배달 https://school.programmers.co.kr/learn/courses/30/lessons/12978 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include using namespace std; vector V[55]; vector Dist; int Min(int A, int B) { if (A 2023. 12. 4.
[Programmers] Lv 2. 줄 서는 방법 https://school.programmers.co.kr/learn/courses/30/lessons/12936 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include using namespace std; //이 문제는 팩토리얼로 전체 경우의 수를 구하고, //거기서 범위를 연산해서 순서를 구해야 함. // //문제의 예시로 설명하면 //n = 3, k = 5일 때, //전체 경우의 수는 3!= > 6. // //이렇게 2마다(전체 경우의 수 / n) 숫자가 바뀜을 알 수 있다. //2마다 숫자가 바뀌는데, k가 .. 2023. 11. 16.
[Programmers] (2021 Dev-Matching: 웹 백엔드 개발자(상반기)) Lv 2. 행렬 테두리 회전하기 https://school.programmers.co.kr/learn/courses/30/lessons/77485 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include using namespace std; enum EDIR { RIGHT, DOWN, LEFT, UP, END }; vector solution(int rows, int columns, vector queries) { vector answer; vector board; const int move[EDIR::END][2] = { { 0, 1 }, { 1, 0 }, { 0.. 2023. 11. 14.
[Programmers] (그리디 or 완전탐색) Lv 2. 마법의 엘리베이터 https://school.programmers.co.kr/learn/courses/30/lessons/148653 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include #include using namespace std; int solution(int storey) { int answer = 0; vector v; auto str = to_string(storey); for (const auto& element : str) v.push_back(element - '0'); int order = v.size() -.. 2023. 11. 10.
[Programmers] Lv 2. 호텔 대실 https://school.programmers.co.kr/learn/courses/30/lessons/155651 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include #include using namespace std; int solution(vector book_time) { vector rooms; std::sort(book_time.begin(), book_time.end()); std::for_each(book_time.begin(), book_time.end(), [&](const auto& v) { .. 2023. 10. 11.
[Programmers] (2020 카카오 인턴십) Lv 2. 수식 최대화 https://school.programmers.co.kr/learn/courses/30/lessons/67257 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include using namespace std; void strtok(vector& v_num, vector& v_op, const char* s) { string temp = ""; while (*s != '\0') { if (*s == '*' || *s == '+' || *s == '-') { v_op.emplace_back(*s); v_num.emplac.. 2023. 10. 10.
[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.