원티드_언리얼RPG 2기/자료구조& 알고리즘(8)
-
<스택> 백준 3986번 좋은 단어
작성한 코드#include #include #include using namespace std;int main(){ stackgWords; int N; cin >> N; int count{}; while (N--) { string input; cin >> input; //입력받은 문자열 스택에 넣기 for (auto c : input) { gWords.push(c); // ABBAB 입력 } // 스택이 빌때까지 반복 while(!gWords.empty()) { //ABABB //ABBAB /// AAA char tmp = gWords.top(); //B..
2025.03.01 -
자료구조 스터디 1주차_ 스택,큐,덱(deque) 구현하기
https://chisel-chocolate-566.notion.site/1-Stack-queue-deque-1a26a793da6280659ce8ffee14b373681주차 스택,큐,덱 발표 덱은 double ended que양 끝에서 삽입 삭제가 가능한 구조 이다.원소의 추가, 제거, 맨 앞/뒤 원소확인시 O(1)의 시간복잡도를 가진다.맨앞/뒤 외의 자료구조는 확인이 불가하다.배열로 구현한 덱, 연결리스트로 구현한 덱, 원형 리스트로 구현한 덱 등이 있다. 연결리스트를 이용한 구현은 다음 주차때 연결리스트를 배우고 하려고 한다. 따라서 이번에는 가장 난이도가 쉬운 배열로 덱의 삽입,삭제 기능을 구현해봤다. 작성코드#include using namespace std;//덱은 시작지점을 배열의 중간에 ..
2025.02.24