LV2

알고리즘 문제/프로그래머스

Lv.2 / 호텔 대실

문제https://school.programmers.co.kr/learn/courses/30/lessons/155651 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 코드#include #include #include #define MAX_TIME 1451using namespace std;int room[MAX_TIME];int getTime(string time) { int hour = stoi(time.substr(0, 2)); int minute = stoi(time.substr(3)); return 60 * hour + min..

알고리즘 문제/프로그래머스

Lv.2 / 마법의 엘리베이터

문제https://school.programmers.co.kr/learn/courses/30/lessons/148653 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 코드#include #include using namespace std;int getCnt(int storey) { if(storey  풀이1의 자리부터 최대 자리까지 0으로 맞춰가면서 진행을 하면 된다.이때, 10단위로 올리냐 0으로 내리냐 두 가지의 경우로 나뉘기 때문에 두 개의 경우에서 최솟값을 확인하여 반환한다.

알고리즘 문제/프로그래머스

Lv.2 / 방문 길이

문제https://school.programmers.co.kr/learn/courses/30/lessons/49994 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 코드#include #include #include #include using namespace std;int dx[4] = {0, -1, 0, 1};int dy[4] = {-1, 0, 1, 0};bool vis[4][11][11]; // 상 우 하 좌int solution(string dirs) { int answer = 0; int r = 5, c = 5; int nr, nc;..

알고리즘 문제/프로그래머스

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 answerSize = number.size() - k; // 뽑아야하는 숫자의 수 int idx = 0; // 탐색 위치 while(answer..

알고리즘 문제/프로그래머스

Lv.2 / N 진수 게임

문제https://school.programmers.co.kr/learn/courses/30/lessons/17687 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 코드(c++)#include #include using namespace std;string getStr(int n, int t, int m) { string result = "0"; int num = 1; // 최대 m 명을 t 만큼만 반복하면됨 while(result.length() 0) { if(tmp % n 코드(Java)import jav..

알고리즘 문제/프로그래머스

Lv.2 / 할인 행사

문제https://school.programmers.co.kr/learn/courses/30/lessons/13112 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 코드( 최적화 전 )#include #include #include using namespace std;unordered_map um;int len = 0;void init(vector want, vector number) { // key = 항목, value = 원하는 수 for(int i=0; i want, vector number, vector discount) { int a..

알고리즘 문제/프로그래머스

Lv.2 / 연속 부분 수열 합의 개수

문제https://school.programmers.co.kr/learn/courses/30/lessons/131701 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 코드#include #include using namespace std;int solution(vector elements) { unordered_set answer; for(int i=0; i 풀이1개부터 전체 길이만큼까지 반복하면서 수행한다. 각 갯수마다 초기 sum 값을 구해준다.그 후, left 와 right 를 잡아 한 칸씩 전진하면서 수행하는데 이 때, 원형 수열이므..

알고리즘 문제/프로그래머스

Lv.2 / 영어 끝말잇기

문제https://school.programmers.co.kr/learn/courses/30/lessons/12981 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 코드#include #include #include #include using namespace std;vector solution(int n, vector words) { vector answer; unordered_set record; int round, num; record.insert(words[0]); for(int i=1; i 풀이unordered_se..

YaHoDev
'LV2' 태그의 글 목록