본문 바로가기
728x90

알고리즘/프로그래머스68

알고리즘(C++) / 프로그래머스 위클리 챌린지 : 4주차 직업군 추천하기 위클리 챌린지 : 4주차 직업군 추천하기 https://programmers.co.kr/learn/courses/30/lessons/84325?language=cpp 코딩테스트 연습 - 4주차 개발자가 사용하는 언어와 언어 선호도를 입력하면 그에 맞는 직업군을 추천해주는 알고리즘을 개발하려고 합니다. 아래 표는 5개 직업군 별로 많이 사용하는 5개 언어에 직업군 언어 점수를 부 programmers.co.kr 코드 //프로그래머스 직업군 추천하기 위클리 챌린지 4주차 #include #include #include #include #include using namespace std; string solution(vector table, vector languages, vector preference) {.. 2021. 8. 31.
알고리즘(C++) / 프로그래머스 level 2 : 카카오 프렌즈 컬러링북 level 2 : 카카오 프렌즈 컬러링북 https://programmers.co.kr/learn/courses/30/lessons/1829 코딩테스트 연습 - 카카오프렌즈 컬러링북 6 4 [[1, 1, 1, 0], [1, 2, 2, 0], [1, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 3], [0, 0, 0, 3]] [4, 5] programmers.co.kr 코드 //프로그래머스 카카오 프렌즈 컬러링북 #include #include #include #include using namespace std; // 전역 변수를 정의할 경우 함수 내에 초기화 코드를 꼭 작성해주세요. bool visited[101][101]; int ni[4], nj[4]; int m_copy; int n.. 2021. 8. 31.
알고리즘(C++) / 프로그래머스 level 2 : 수식 최대화 level 2 : 수식 최대화 https://programmers.co.kr/learn/courses/30/lessons/67257?language=cpp 코딩테스트 연습 - 수식 최대화 IT 벤처 회사를 운영하고 있는 라이언은 매년 사내 해커톤 대회를 개최하여 우승자에게 상금을 지급하고 있습니다. 이번 대회에서는 우승자에게 지급되는 상금을 이전 대회와는 다르게 다음과 programmers.co.kr 코드 //프로그래머스 수식 최대화 #include #include #include #include //절대값 #include using namespace std; vector operation = { {"*", "+", "-"},{"*", "-", "+"}, {"+", "*", "-"}, {"+", "-",.. 2021. 8. 29.
알고리즘(C++) / 프로그래머스 level 2 : 순위 검색 level 2 : 순위 검색 https://programmers.co.kr/learn/courses/30/lessons/72412?language=cpp > person[1] >> person[2] >> person[3] >> person[4]; combination(person); //조합찾기 } for (auto& score : m) { sort(score.second.begin(), score.second.end()); //score 순으로 정렬 } for (int i = 0; i > person[0] >> a >> person[1] >> .. 2021. 8. 29.
알고리즘(C++) / 프로그래머스 level 2 : 튜플 level 2 : 튜플 https://programmers.co.kr/learn/courses/30/lessons/64065?language=cpp 코딩테스트 연습 - 튜플 "{{2},{2,1},{2,1,3},{2,1,3,4}}" [2, 1, 3, 4] "{{1,2,3},{2,1},{1,2,4,3},{2}}" [2, 1, 3, 4] "{{4,2,3},{3},{2,3,4,1},{2,3}}" [3, 2, 4, 1] programmers.co.kr 코드 //프로그래머스 튜플 #include #include #include #include #include #include using namespace std; //size 내림차순으로 정렬 bool cmp(const pair& a, const pair& b) { .. 2021. 8. 27.
알고리즘(C++) / 프로그래머스 level 2 : 프렌즈4블록 level 2 : 프렌즈4블록 https://programmers.co.kr/learn/courses/30/lessons/17679?language=cpp 코딩테스트 연습 - [1차] 프렌즈4블록 프렌즈4블록 블라인드 공채를 통과한 신입 사원 라이언은 신규 게임 개발 업무를 맡게 되었다. 이번에 출시할 게임 제목은 "프렌즈4블록". 같은 모양의 카카오프렌즈 블록이 2×2 형태로 4개가 붙 programmers.co.kr 코드 //프로그래머스 프렌즈4블록 #include #include #include #include using namespace std; int ni[3] = { 0,1,1 }, nj[3] = { 1,0,1 }; //2x2형태인지 확인 bool Block4(int i, int j, vec.. 2021. 8. 25.
알고리즘(C++) / 프로그래머스 level 2 : 방금그곡 level 2 : 방금그곡 https://programmers.co.kr/learn/courses/30/lessons/17683?language=cpp 코딩테스트 연습 - [3차] 방금그곡 방금그곡 라디오를 자주 듣는 네오는 라디오에서 방금 나왔던 음악이 무슨 음악인지 궁금해질 때가 많다. 그럴 때 네오는 다음 포털의 '방금그곡' 서비스를 이용하곤 한다. 방금그곡에서는 TV, programmers.co.kr 코드 //프로그래머스 방금 그곡 #include #include #include using namespace std; //재생 시간 구하기 int Play_time(string musicinfo) { int start_h = stoi(musicinfo.substr(0, 2)); int start_m .. 2021. 8. 24.
알고리즘(C++) / 프로그래머스 level 2 : 메뉴 리뉴얼 level 2 : 메뉴 리뉴얼 https://programmers.co.kr/learn/courses/30/lessons/72411?language=cpp# 코딩테스트 연습 - 메뉴 리뉴얼 레스토랑을 운영하던 스카피는 코로나19로 인한 불경기를 극복하고자 메뉴를 새로 구성하려고 고민하고 있습니다. 기존에는 단품으로만 제공하던 메뉴를 조합해서 코스요리 형태로 재구성해서 programmers.co.kr 내 코드 //프로그래머스 메뉴 리뉴얼 #include #include #include #include #include #include using namespace std; bool cmp(const pair& a, const pair& b) { if(a.first.size() == b.first.size()).. 2021. 8. 23.
알고리즘(C++) / 프로그래머스 level 2 : 오픈채팅방 level 2 : 오픈채팅방 https://programmers.co.kr/learn/courses/30/lessons/42888?language=cpp 코딩테스트 연습 - 오픈채팅방 오픈채팅방 카카오톡 오픈채팅방에서는 친구가 아닌 사람들과 대화를 할 수 있는데, 본래 닉네임이 아닌 가상의 닉네임을 사용하여 채팅방에 들어갈 수 있다. 신입사원인 김크루는 카카오톡 오 programmers.co.kr 코드 //프로그래머스 오픈채팅방 #include #include #include #include using namespace std; string in = "님이 들어왔습니다."; string out = "님이 나갔습니다."; //in out 문장 vector solution(vector record) { ve.. 2021. 8. 22.
알고리즘(C++) / 프로그래머스 level 3 : 베스트앨범 level 3 : 베스트앨범 https://programmers.co.kr/learn/courses/30/lessons/42579?language=cpp 코딩테스트 연습 - 베스트앨범 스트리밍 사이트에서 장르 별로 가장 많이 재생된 노래를 두 개씩 모아 베스트 앨범을 출시하려 합니다. 노래는 고유 번호로 구분하며, 노래를 수록하는 기준은 다음과 같습니다. 속한 노래가 programmers.co.kr 코드 //프로그래머스 베스트앨범 #include #include #include #include #include #include using namespace std; bool cmp(pair & a, pair& b) { return a.second > b.second; } //내림차순 bool cmp_play.. 2021. 8. 19.
알고리즘(C++) / 프로그래머스 위클리 챌린지 2주차 : 상호평가 위클리 챌린지 2주차 : 상호평가 https://programmers.co.kr/learn/courses/30/lessons/83201?language=cpp 코딩테스트 연습 - 2주차 [[100,90,98,88,65],[50,45,99,85,77],[47,88,95,80,67],[61,57,100,80,65],[24,90,94,75,65]] "FBABD" [[70,49,90],[68,50,38],[73,31,100]] "CFD" programmers.co.kr 코드 //프로그래머스 상호 평가 #include #include #include #include #include using namespace std; string solution(vector scores) { string answer = ""; .. 2021. 8. 12.
알고리즘(C++) / 프로그래머스 level 3 : 섬 연결하기 level 3 : 섬 연결하기 https://programmers.co.kr/learn/courses/30/lessons/42861?language=cpp# 코딩테스트 연습 - 섬 연결하기 4 [[0,1,1],[0,2,2],[1,2,5],[1,3,1],[2,3,8]] 4 programmers.co.kr 코드 //프로그래머스 섬 연결하기 #include #include #include #include using namespace std; bool visited[101] = { false, }; bool cmp(const vector& a, const vector& b) { return a[2] < b[2]; } int solution(int n, vector costs) { int answer = 0; s.. 2021. 8. 12.