목록Problem Solving (223)
Life Engineering
https://programmers.co.kr/learn/courses/30/lessons/77485 코딩테스트 연습 - 행렬 테두리 회전하기 6 6 [[2,2,5,4],[3,3,6,6],[5,1,6,3]] [8, 10, 25] 3 3 [[1,1,2,2],[1,2,2,3],[2,1,3,2],[2,2,3,3]] [1, 1, 5, 3] programmers.co.kr #include #include #include using namespace std; int matrix[101][101]; int move(int x1, int y1, int x2, int y2){ int x=x1; int y=y1; int temp=matrix[x1+1][y1]; int val; vector v; while (yx1){ va..
https://programmers.co.kr/learn/courses/30/lessons/12973# 코딩테스트 연습 - 짝지어 제거하기 짝지어 제거하기는, 알파벳 소문자로 이루어진 문자열을 가지고 시작합니다. 먼저 문자열에서 같은 알파벳이 2개 붙어 있는 짝을 찾습니다. 그다음, 그 둘을 제거한 뒤, 앞뒤로 문자열을 이어 붙 programmers.co.kr #include #include #include using namespace std; int solution(string s) { stack st; int pos=0; while (pos문자를 넣어주고 스택의 탑과 지금 넣으려는 애가 같으면->스택의 탑을 pop 해준다(짝지어 제거하는 방식) 서로 다르면=>그 문자를 push 해준다 다음 문자로 이..
https://programmers.co.kr/learn/courses/30/lessons/49189 코딩테스트 연습 - 가장 먼 노드 6 [[3, 6], [4, 3], [3, 2], [1, 3], [1, 2], [2, 4], [5, 2]] 3 programmers.co.kr #include #include #include #include #define MAX 987654321 using namespace std; class Node{ public: int id; int cost; Node(int id, int cost) : id(id), cost(cost) {} }; struct compare{ bool operator()(Node a, Node b){ return a.cost>b.cost; } }; ..
https://programmers.co.kr/learn/courses/30/lessons/42627 코딩테스트 연습 - 디스크 컨트롤러 하드디스크는 한 번에 하나의 작업만 수행할 수 있습니다. 디스크 컨트롤러를 구현하는 방법은 여러 가지가 있습니다. 가장 일반적인 방법은 요청이 들어온 순서대로 처리하는 것입니다. 예를 programmers.co.kr #include #include #include #include using namespace std; struct Job{ int request, time; Job(int request, int time) : request(request), time(time) {} }; struct compare{ bool operator()(Job a, Job b){ r..