알고리즘
-
문제 내용https://school.programmers.co.kr/learn/courses/30/lessons/43164 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 풀이 내용알파벳 순으로 경로 출력 위해 sort함sort한 상태로 dfs 돌며 경로 찾음경로 끝까지 갔을때(다 찾았을때)의 예외처리를 잘못해서 좀 헤맸다.. 짱ㄴㅏ.. 사실 ICN을 첨부터 push 안하고 바로 dfs 돌면서 start를 push해도 되긴하는데문제에서 고정값으로 준 ICN라 그냥 직역해서 풀었다 풀이 코드#include #include #include using namespace std;bool visit[10000+2..
[C++] 프로그래머스 lv3 여행경로 (DFS)문제 내용https://school.programmers.co.kr/learn/courses/30/lessons/43164 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 풀이 내용알파벳 순으로 경로 출력 위해 sort함sort한 상태로 dfs 돌며 경로 찾음경로 끝까지 갔을때(다 찾았을때)의 예외처리를 잘못해서 좀 헤맸다.. 짱ㄴㅏ.. 사실 ICN을 첨부터 push 안하고 바로 dfs 돌면서 start를 push해도 되긴하는데문제에서 고정값으로 준 ICN라 그냥 직역해서 풀었다 풀이 코드#include #include #include using namespace std;bool visit[10000+2..
2025.03.03 -
문제프로그래머스 DFS/BFS - 단어 변환https://school.programmers.co.kr/learn/courses/30/lessons/43163 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 문제 풀이단어 변환을 위한 '최소 횟수'를 구하기 위해 bfs 사용 (최단거리와 동일한 개념으로 접근)bfs를 돌며, 현재 비교하는 대상 단어와 변환 횟수를 pair로 묶어서 반복문자열간 비교를 이렇게밖에 못하나? 고민했으나..find 함수라는 것도 서치해봤지만 오히려 더 복잡해질거라 판단. 풀이 코드#include #include #include using namespace std;int answer..
[C++] 프로그래머스 lv3 단어 변환 (BFS)문제프로그래머스 DFS/BFS - 단어 변환https://school.programmers.co.kr/learn/courses/30/lessons/43163 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 문제 풀이단어 변환을 위한 '최소 횟수'를 구하기 위해 bfs 사용 (최단거리와 동일한 개념으로 접근)bfs를 돌며, 현재 비교하는 대상 단어와 변환 횟수를 pair로 묶어서 반복문자열간 비교를 이렇게밖에 못하나? 고민했으나..find 함수라는 것도 서치해봤지만 오히려 더 복잡해질거라 판단. 풀이 코드#include #include #include using namespace std;int answer..
2025.03.03 -
https://school.programmers.co.kr/learn/courses/30/lessons/131533 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr SELECT p.product_code, sum(o.sales_amount*p.price) as sales from product p, offline_sale o where p.product_id = o.product_id group by p.product_code order by sales desc, p.product_code; group by 약간 헷갈린닷 .. 처음에 sum(o.sales_..
[oracle] 프로그래머스 SQL 고득점 Kit - 상품 별 오프라인 매출 구하기https://school.programmers.co.kr/learn/courses/30/lessons/131533 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr SELECT p.product_code, sum(o.sales_amount*p.price) as sales from product p, offline_sale o where p.product_id = o.product_id group by p.product_code order by sales desc, p.product_code; group by 약간 헷갈린닷 .. 처음에 sum(o.sales_..
2023.10.12 -
https://school.programmers.co.kr/learn/courses/30/lessons/131115 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr SELECT * from food_product where price = ( select max(price) from food_product );
[oracle] max 함수, 프로그래머스 Lv2 가격이 제일 비싼 식품의 정보 출력하기https://school.programmers.co.kr/learn/courses/30/lessons/131115 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr SELECT * from food_product where price = ( select max(price) from food_product );
2023.10.12 -
NVL 함수 NVL(expr1, expr2) : expr1이 null이 아니라면 expr1값을 출력. null이라면 expr2값을 출력 예시 SELECT animal_type, NVL(name,'No name') as name, sex_upon_intake from ANIMAL_INS order by animal_id; https://school.programmers.co.kr/learn/courses/30/lessons/59410?language=oracle 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr NVL2 함수 NVL2(expr1, expr2, ..
[oracle] NVL함수, 프로그래머스 Lv2 NULL 처리하기NVL 함수 NVL(expr1, expr2) : expr1이 null이 아니라면 expr1값을 출력. null이라면 expr2값을 출력 예시 SELECT animal_type, NVL(name,'No name') as name, sex_upon_intake from ANIMAL_INS order by animal_id; https://school.programmers.co.kr/learn/courses/30/lessons/59410?language=oracle 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr NVL2 함수 NVL2(expr1, expr2, ..
2023.10.12 -
나는야 졸리면 레벨원 푸는 사람 레벨투 .. 다시 낼부터 고 ㅎ 무튼 풀다가 잘 안써버릇한 메소드가 있어서 겟겟 ㅎㅎ 아래 문제 풀이 중 https://school.programmers.co.kr/learn/courses/30/lessons/12935 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 내가 탐낸 풀이 #include #include using namespace std; vector solution(vector arr) { if (arr.size() == 1) { return { -1 }; } arr.erase(min_element(arr.be..
[C++] min_element로 최소값 원소 찾기, erase로 원소 지우기나는야 졸리면 레벨원 푸는 사람 레벨투 .. 다시 낼부터 고 ㅎ 무튼 풀다가 잘 안써버릇한 메소드가 있어서 겟겟 ㅎㅎ 아래 문제 풀이 중 https://school.programmers.co.kr/learn/courses/30/lessons/12935 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 내가 탐낸 풀이 #include #include using namespace std; vector solution(vector arr) { if (arr.size() == 1) { return { -1 }; } arr.erase(min_element(arr.be..
2023.10.02 -
맨날 까먹고 헷갈려하는거 정리정리 .. sort 함수 #include #include ... vector newArr; sort(newArr.begin(), newArr.end(),greater()); sort함수 시간복잡도는 n log n sort 정렬시 인자를 배열로 줄땐 sort(arr,arr+n); sort 정렬시 인자를 벡터로 줄땐 sort(v.begin(), v.end()); 내림차순 sort 내림차순 정렬을 하고싶을땐 sort( ~ , ~, greater() ); 이렇게 세번째 인수로 greater() 함수 넣어주기 문자 long long으로 변환 string to long long stoll(string); long long to string to_string(long long) 참고) 종..
[C++] sort, greater<>, stoll, 숫자를 문자열로, sqrt맨날 까먹고 헷갈려하는거 정리정리 .. sort 함수 #include #include ... vector newArr; sort(newArr.begin(), newArr.end(),greater()); sort함수 시간복잡도는 n log n sort 정렬시 인자를 배열로 줄땐 sort(arr,arr+n); sort 정렬시 인자를 벡터로 줄땐 sort(v.begin(), v.end()); 내림차순 sort 내림차순 정렬을 하고싶을땐 sort( ~ , ~, greater() ); 이렇게 세번째 인수로 greater() 함수 넣어주기 문자 long long으로 변환 string to long long stoll(string); long long to string to_string(long long) 참고) 종..
2023.09.28 -
하핫 돌아오는 월욜(내일)부터 하루에 세문제씩 풀기로 계획세웠는데 ㅎ 할수있겠지 ㅎ 한문제 풀고 나면 그냥 집가고싶어짐 ㅎ 무튼 .. 정답 코드 #include #include using namespace std; vector solution(int n, vector words) { vector answer; string before = words[0]; for(int i=1;i
[프로그래머스] level2 영어 끝말잇기 - c++하핫 돌아오는 월욜(내일)부터 하루에 세문제씩 풀기로 계획세웠는데 ㅎ 할수있겠지 ㅎ 한문제 풀고 나면 그냥 집가고싶어짐 ㅎ 무튼 .. 정답 코드 #include #include using namespace std; vector solution(int n, vector words) { vector answer; string before = words[0]; for(int i=1;i
2023.07.16