바킹독 알고리즘 문제집 - 연결 리스트
·
알고리즘/Algorithm
1406번 : 에디터 - silver 2 #include #include #include using namespace std; int main(void){ string str; cin>>str; list l; for(auto s:str) l.push_back(s); // list에 문자 순서대로 넣기 auto now = l.end(); // list::iterator cur = l.end() int q; cin>>q; while(q--){ // q만큼 돈다 char c; cin>>c; if(c=='P'){ // 왼쪽에 문자 추가 char w; cin>>w; l.insert(now, w); // 왼쪽 위치에 w 추가 }else if(c=='L'){ if(now!=l.begin()) now--; // 왼쪽으..
SW Academy D1 -2
·
알고리즘/Algorithm
2050. 알파벳을 숫자로 변환 #include #include #include using namespace std; int main(void){ string str; cin>>str; for(int i=0;i
SW Academy D1 -1
·
알고리즘/Algorithm
2072. 홀수만 출력하기 #include using namespace std; int main(int argc, char** argv) { int test_case; int T,n; cin>>T; for(test_case = 1; test_case n; if(n%2==1) sum+=n; } cout
Algorithm C++ [220118] :: Greedy - 1 (이것이 코딩테스트다 학습 정리)
·
알고리즘/Algorithm
Greedy :: 현재에서 지금 당장 좋은것만 고르는 방법 Floyes-warshall Dijkstra 가장 큰 순서/ 가장 작은 순서 문제는 정렬 알고리즘을 사용 [예제 3-1] 거스름돈(Greedy 기초문제) 문제 당신은 음식점의 점원. 카운터에는 거스름돈으로 500원/100/50/10원 동전이 무한히 존재한다고 가정. 손님에게 거슬러 줘야 할 돈이 N원일 때 거슬러 줘야 할 동전의 최소 개수를 구해라. 단, 거슬러 줘야 할 돈 N은 항상 10의 배수이다. 문제 해설 1. 가장 큰 화폐 단위부터 돈을 거슬러 주기 → 최소의 동전 개수로 모두 거슬러 주기 가능. 2. 화폐의 종류만큼 반복 수행해야 함. 3. 화폐의 종류가 K개일 경우, 위 소스코드의 시간 복잡도는 O(K)이다. n은 거슬러 줘야할 돈...
TaffyMuffin
'algorithm' 태그의 글 목록