๊ฐ์ฅ ๋จผ ๋ ธ๋ https://programmers.co.kr/learn/courses/30/lessons/49189 ์ฝ๋ #include #include #include #include #include using namespace std; int solution(int n, vector edge) { int answer = 0; map linked_list; set list; list.insert(1); // ์ฐ๊ฒฐ ๋ฆฌ์คํธ ๋ง๋ค๊ธฐ int size = edge.size(); for(int i=0; i
๋ผ๋ฉด๊ณต์ฅ https://programmers.co.kr/learn/courses/30/lessons/42629# ์ฝ๋ #include #include #include using namespace std; vector node; int solution(int stock, vector dates, vector supplies, int k) { int answer = 0; int day = stock; int size = dates.size(); for (int i = 0; i < size; i++) { node.push_back(make_pair(dates[i], supplies[i])); } while (day < k) { int idx = 0; int max_idx = 0; while (idx < nod..
ํ https://programmers.co.kr/learn/courses/30/lessons/42588?language=cpp ์ฝ๋ #include #include #include using namespace std; vector solution(vector heights) { int heights_len = heights.size(); vector answer(heights_len); stack stk; // index, key for (int i = heights_len - 1; i>0; i--) { if (heights[i - 1] > heights[i]) { answer[i] = i; // stack while (stk.size() != 0) { auto tmp = stk.top(); if (h..
์นดํซ ์ฝ๋ #include #include #include using namespace std; vector solution(int brown, int yellow) { vector answer; vector candidate; for (int i = 1; i ๋ง์ผ๋ฉด (๊ฐ๋ก, ์ธ๋ก) ๊ธธ์ด๋ฅผ ๊ฒฐ๊ณผ vector์ ๋ฃ์ด์ return brown ๊ฐฏ์ = 2*๊ฐ๋กyellow + 2*์ธ๋กyellow +4 4 : ์์ชฝ ๋ชจ์๋ฆฌ ๋ค๋ฅธ ์ฌ๋์ ์ฝ๋ #include #include using namespace std; vector solution(int brown, int red) { int len = brown / 2 + 2; int w = len - 3; int h = 3; while(w >= h){ if(w * h ..
์ซ์์ผ๊ตฌ ์ฝ๋ #include #include using namespace std; bool check(int* arr, vector& bb) { int num = bb[0]; int s = bb[1]; int b = bb[2]; int n[3]; n[0] = num / 100; n[1] = (num - n[0] * 100) / 10; n[2] = (num - n[0] * 100 - n[1] * 10); //strike check int t_num = 0; for (int i = 0; i < 3; i++) { if (n[i] == arr[i]) t_num++; } if (t_num != s) return false; t_num = 0; for (int i = 0; i < 3; i++) { if (n[i]..
https://programmers.co.kr/learn/courses/30/lessons/42839 ์ฝ๋ #include #include #include #include using namespace std; set res; void test(int num) { if (num num์ด ์ต๋ 9999999 (10^7) if (num%i == 0) return; } res.insert(num); return; } void makePrime(vector& memo,int num) { if (memo.size()==0) return; int size = memo.size(); for (int i = 0; i < size; i++) { // 7 int value = memo[i]; test(num * 10 + v..
https://programmers.co.kr/learn/courses/30/lessons/42840 ๋์ถฉ ํ๋ฉด ์ฌ์ด ๋ฌธ์ . ์ฝ๋๋ฅผ ๊ฐ๊ฒฐํ๊ณ ๋ช ํํ๊ฒ ์ฐ๋ ๊ฑธ ์ฐ์ตํ์. ์ฝ๋ #include #include #include using namespace std; vector solution(vector answers) { vector answer; int size = answers.size(); int correct[3] = { 0,0,0 }; int secondList[4] = { 1,3,4,5 }; int thirdList[5] = { 3,1,2,4,5 }; for (int i = 0; icorrect[1]) { if (correct[1] >= correct[2]) { answer.push_back(1..
https://programmers.co.kr/learn/courses/30/lessons/42895 ๋ฌธ์ ์ค๋ช ์๋์ ๊ฐ์ด 5์ ์ฌ์น์ฐ์ฐ๋ง์ผ๋ก 12๋ฅผ ํํํ ์ ์์ต๋๋ค. 12 = 5 + 5 + (5 / 5) + (5 / 5) 12 = 55 / 5 + 5 / 5 12 = (55 + 5) / 5 5๋ฅผ ์ฌ์ฉํ ํ์๋ ๊ฐ๊ฐ 6,5,4 ์ ๋๋ค. ๊ทธ๋ฆฌ๊ณ ์ด์ค ๊ฐ์ฅ ์์ ๊ฒฝ์ฐ๋ 4์ ๋๋ค. ์ด์ฒ๋ผ ์ซ์ N๊ณผ number๊ฐ ์ฃผ์ด์ง ๋, N๊ณผ ์ฌ์น์ฐ์ฐ๋ง ์ฌ์ฉํด์ ํํ ํ ์ ์๋ ๋ฐฉ๋ฒ ์ค N ์ฌ์ฉํ์์ ์ต์๊ฐ์ return ํ๋๋ก solution ํจ์๋ฅผ ์์ฑํ์ธ์. ์ ํ์ฌํญ N์ 1 ์ด์ 9 ์ดํ์ ๋๋ค. number๋ 1 ์ด์ 32,000 ์ดํ์ ๋๋ค. ์์์๋ ๊ดํธ์ ์ฌ์น์ฐ์ฐ๋ง ๊ฐ๋ฅํ๋ฉฐ ๋๋๊ธฐ ์ฐ์ฐ์์ ๋๋จธ์ง๋ ๋ฌด์ํฉ..
Comment