[c++] 프로그래머스 - 게임 맵 최단거리 (Level 2)
문제 코딩테스트 연습 - 게임 맵 최단거리 [[1,0,1,1,1],[1,0,1,0,1],[1,0,1,1,1],[1,1,1,0,1],[0,0,0,0,1]] 11 [[1,0,1,1,1],[1,0,1,0,1],[1,0,1,1,1],[1,1,1,0,0],[0,0,0,0,1]] -1 programmers.co.kr 코드 #include #include #include using namespace std; int map[101][101]; int dx[4]={0,0,-1,1}; int dy[4]={-1,1,0,0}; int n1,n2; void bfs(int x,int y){ queueq; q.push({x,y}); while (!q.empty()) { int x=q.front().first; int y=q.fro..
2021. 10. 19.
[c++] 프로그래머스 - 거리두기 확인하기 ( Level 2, 2021 카카오 인턴십)
코딩테스트 연습 - 거리두기 확인하기 [["POOOP", "OXXOX", "OPXPX", "OOXOX", "POXXP"], ["POOPX", "OXPXP", "PXXXO", "OXXXO", "OOOPP"], ["PXOPX", "OXOXP", "OXPOX", "OXXOP", "PXPOX"], ["OOOXX", "XOOOX", "OOOXX", "OXOOX", "OOOOO"], ["PXPXP", "XPXPX", "PXPXP", "XPXPX", "PXPXP"]] [1, 0, 1, 1, 1] programmers.co.kr #include #include #include using namespace std; int visited[6][6]; string map[6][6]; int dx[4]={0,0,-1,1}; ..
2021. 10. 19.
[c++] 프로그래머스 - 가장 큰 수 (Level 2)
코딩테스트 연습 - 가장 큰 수 0 또는 양의 정수가 주어졌을 때, 정수를 이어 붙여 만들 수 있는 가장 큰 수를 알아내 주세요. 예를 들어, 주어진 정수가 [6, 10, 2]라면 [6102, 6210, 1062, 1026, 2610, 2106]를 만들 수 있고, 이중 가장 큰 programmers.co.kr #include #include #include using namespace std; bool cmp(string a, string b){ if(a.length()!=b.length()) return stoi(a+b)>stoi(b+a); else return stoi(a)>stoi(b); } string solution(vector numbers) { string answer = ""; vector..
2021. 10. 19.
[c++] 프로그래머스 - K번째 수 ( Level 1)
코딩테스트 연습 - K번째수 [1, 5, 2, 6, 3, 7, 4] [[2, 5, 3], [4, 4, 1], [1, 7, 3]] [5, 6, 3] programmers.co.kr #include #include #include using namespace std; vector solution(vector array, vector commands) { vector answer; for(int i=0; i
2021. 10. 19.