LV2

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

Lv.2 / 피보나치 수

문제https://school.programmers.co.kr/learn/courses/30/lessons/12945 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 코드#include #include #define MAX 100001#define MOD 1234567using namespace std;int fibo[MAX];int solution(int n) { fibo[1] = 1; fibo[2] = 1; if(n == 2) return 1; for(int i=3; i 풀이n 번째 피보나치 수는 n-1 번째와 n-2 번..

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

Lv.2 / 다음 큰 숫자

문제https://school.programmers.co.kr/learn/courses/30/lessons/12911 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 코드#include #include using namespace std;int getOneCnt(int n) { int oneCnt = 0; while(n > 0) { if(n % 2 == 1) oneCnt++; n /= 2; } return oneCnt;}int solution(int n) { int original = getOneCnt(n);..

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

Lv.2 / 숫자의 표현

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

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

Lv.2 / 이진 변환 반복하기

문제https://school.programmers.co.kr/learn/courses/30/lessons/70129 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr  코드#include #include #include using namespace std;vector solution(string s) { vector answer; int cnt = 0; int zeroCnt = 0; while(s != "1") { cnt++; string tmp = ""; for(int i=0; i 0) { ..

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

Lv.2 / JadenCase 문자열 만들기

문제https://school.programmers.co.kr/learn/courses/30/lessons/12951 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr  코드#include #include #include using namespace std;string solution(string s) { string answer = ""; bool upper = true; for(int i=0; i 풀이upper 라는 boolean 변수를 두어 단어의 시작인지 아닌지를 확인한다. 만약 upper 가 true 라면 단어의 시작이므로 소문자..

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

Lv.2 / 최솟값 만들기

문제https://school.programmers.co.kr/learn/courses/30/lessons/12941 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr  코드#include #include #include using namespace std;int solution(vector A, vector B){ int answer = 0; sort(A.begin(), A.end()); sort(B.rbegin(), B.rend()); for(int i=0; i 풀이두 배열 중 한 배열(A)은 오름차순, 다른 배열(B)은 내림차순..

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

Lv.2 / 올바른 괄호

문제https://school.programmers.co.kr/learn/courses/30/lessons/12909 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr  코드#include #include using namespace std;bool solution(string s){ stack st; for(int i=0; i 풀이대표적인 스택 문제로 '(' 를 만나면 push, ')' 를 만나면 현재 스택의 top 과 비교하며 문제 해결

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

Lv.2 / 최댓값과 최솟값

문제https://school.programmers.co.kr/learn/courses/30/lessons/12939 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr  코드#include #include #include using namespace std;string solution(string s) { string answer = ""; string tmp; int mini = 987654321; int maxi = -987654321; for(int i=0; i 풀이공백을 만날 때마다 정수로 변환하여 최소, 최대를 ..

YaHoDev
'LV2' 태그의 글 목록 (3 Page)